10 float( string pStr ) Util_GetAltStringCount =
14 local float lPosition;
17 lPosition = lCount = 0;
18 for( lLength = strlen( pStr ) ; lPosition < lLength ; lPosition++ ) {
19 lLetter = substring( pStr, lPosition, 1 );
22 else if( lLetter == "\\" )
26 return floor( lCount / 2 );
34 string( string pStr, float pCount ) Util_GetAltStringItem =
37 local float lPosition;
42 pCount = pCount*2 + 1; // number of ' until item starts
43 lCount = lPosition = 0;
44 for( lLength = strlen( pStr ) ; lPosition < lLength && lCount < pCount ; lPosition++ ) {
45 lLetter = substring( pStr, lPosition, 1 );
49 else if( lLetter == "\\" )
53 if( lCount != pCount )
54 return String_Create();
56 for( lOut = "" ; lPosition < lLength ; lPosition++ ) {
57 lLetter = substring( pStr, lPosition, 1 );
61 else if( lLetter == "\\" ) {
63 if( lPosition >= lLength )
65 lLetter = substring( pStr, lPosition, 1 );
68 lOut = strcat( lOut, lLetter ); // no need for strzone since there are 16 buffers and we use 2 in the for
71 return String_Zone( lOut ); // return a strzoned string
74 float( string pStr ) Util_GetAltStringCount =
76 return altstr_count( pStr );
78 string( string pStr, float pCount ) Util_GetAltStringItem =
80 return String_Zone( altstr_get( pStr, pCount ) );
91 string( string pAlt, float pIndex, string pSet ) Util_SetAltStringItem =
94 local float lPosition;
100 pSet = String_Zone( pSet );
102 pIndex = pIndex*2 + 1; // number of ' until item starts
103 lCount = lPosition = 0;
104 for( lLength = strlen( pAlt ) ; lPosition < lLength && lCount < pIndex ; lPosition = lPosition + 1 ) {
105 lLetter = substring( pAlt, lPosition, 1 );
109 else if( lLetter == "\\" )
110 lPosition = lPosition + 1;
113 if( lCount != pIndex )
117 // find the end of it
118 for( ; lPosition < lLength ; lPosition++ ) {
119 lLetter = substring( pAlt, lPosition, 1 );
123 else if( lLetter == "\\" )
124 lPosition = lPosition + 1;
127 lOut = String_Substring( pAlt, 0, lStart );
128 pSet = Util_AltStringPrepare( String_Normal( pSet ) );
129 lOut = strcat( lOut, String_Normal( pSet ), substring( pAlt, lPosition, lLength - lPosition ) );
131 return String_Set( pAlt, lOut );
134 string( string pAlt, float pIndex, string pSet ) Util_SetAltStringItem =
136 return String_Set( pAlt, altstr_set( pAlt, pIndex, pSet ) );
142 Util_DelAltStringItem
145 string( string pAlt, float pIndex ) Util_DelAltStringItem =
148 local float lPosition;
151 local string lLetter;
154 pIndex = pIndex*2 + 1; // number of ' until item starts
155 lCount = lPosition = 0;
156 for( lLength = strlen( pAlt ) ; lPosition < lLength && lCount < pIndex ; lPosition = lPosition + 1 ) {
157 lLetter = substring( pAlt, lPosition, 1 );
161 else if( lLetter == "\\" )
162 lPosition = lPosition + 1;
165 if( lCount != pIndex )
169 // find the end of it
170 for( ; lPosition < lLength ; lPosition++ ) {
171 lLetter = substring( pAlt, lPosition, 1 );
175 else if( lLetter == "\\" )
176 lPosition = lPosition + 1;
180 lOut = substring( pAlt, 0, lStart - 1 );
181 if( lPosition < lLength - 1)
182 lOut = strcat( lOut, substring( pAlt, lPosition + 1, lLength - lPosition - 1) );
184 return String_Set( pAlt, lOut );
189 Util_AltStringPrepare
193 string( string pString ) Util_AltStringPrepare =
195 local string lOut, lChar;
196 local float lPos, lLength;
198 pString = String_Zone( pString );
201 lLength = strlen( pString );
202 for( lPos = 0; lPos < lLength ; lPos = lPos + 1 ) {
203 lChar = substring( pString, lPos, 1 );
206 lOut = strcat( lOut, lChar );
209 String_Free( pString );
210 return String_Zone( lOut );
213 string( string pString ) Util_AltStringPrepare =
215 return String_Zone( altstr_prepare( pString ) );
224 string( string pAlt, string pPush ) Util_AltStringPush =
226 return String_Set( pAlt, strcat( "'", String_Normal( Util_AltStringPrepare( pPush ) ), "'", pAlt ) );
234 string( string pAlt ) Util_GetAltStringTop =
236 return Util_GetAltStringItem( pAlt, 0 );
244 string( string pAlt ) Util_AltStringPop =
246 local float lPos, lCount, lLength;
250 lLength = strlen( pAlt );
251 for( lPos = 0 ; lPos < lLength && lCount < 2 ; lPos++) {
252 lChar = substring( pAlt, lPos, 1 );
255 else if( lChar == "'" )
259 return String_Set( pAlt, substring( pAlt, lPos, lLength - lPos ) ); // no - 1 because this time we dont break after the '