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 // no need for strzone since there are 16 buffers and we use 2 in the for
69 lOut = strcat( lOut, lLetter );
72 return String_Zone( lOut ); // return a strzoned string
75 float( string pStr ) Util_GetAltStringCount =
77 return altstr_count( pStr );
79 string( string pStr, float pCount ) Util_GetAltStringItem =
81 return String_Zone( altstr_get( pStr, pCount ) );
92 string( string pAlt, float pIndex, string pSet ) Util_SetAltStringItem =
95 local float lPosition;
101 pSet = String_Zone( pSet );
103 pIndex = pIndex*2 + 1; // number of ' until item starts
104 lCount = lPosition = 0;
105 for( lLength = strlen( pAlt ) ; lPosition < lLength && lCount < pIndex ; lPosition = lPosition + 1 ) {
106 lLetter = substring( pAlt, lPosition, 1 );
110 else if( lLetter == "\\" )
111 lPosition = lPosition + 1;
114 if( lCount != pIndex )
118 // find the end of it
119 for( ; lPosition < lLength ; lPosition++ ) {
120 lLetter = substring( pAlt, lPosition, 1 );
124 else if( lLetter == "\\" )
125 lPosition = lPosition + 1;
128 lOut = String_Substring( pAlt, 0, lStart );
129 pSet = String_Normal( Util_AltStringPrepare( String_Normal( pSet ) ) );
130 lOut = strcat( lOut, pSet, substring( pAlt, lPosition, lLength - lPosition ) );
132 return String_Set( pAlt, lOut );
135 string( string pAlt, float pIndex, string pSet ) Util_SetAltStringItem =
137 return String_Set( pAlt, altstr_set( pAlt, pIndex, pSet ) );
143 Util_DelAltStringItem
146 string( string pAlt, float pIndex ) Util_DelAltStringItem =
149 local float lPosition;
152 local string lLetter;
155 pIndex = pIndex*2 + 1; // number of ' until item starts
156 lCount = lPosition = 0;
157 for( lLength = strlen( pAlt ) ; lPosition < lLength && lCount < pIndex ; lPosition = lPosition + 1 ) {
158 lLetter = substring( pAlt, lPosition, 1 );
162 else if( lLetter == "\\" )
163 lPosition = lPosition + 1;
166 if( lCount != pIndex )
170 // find the end of it
171 for( ; lPosition < lLength ; lPosition++ ) {
172 lLetter = substring( pAlt, lPosition, 1 );
176 else if( lLetter == "\\" )
177 lPosition = lPosition + 1;
181 lOut = substring( pAlt, 0, lStart - 1 );
182 if( lPosition < lLength - 1)
183 lOut = strcat( lOut, substring( pAlt, lPosition + 1, lLength - lPosition - 1) );
185 return String_Set( pAlt, lOut );
190 Util_InsAltStringItem
194 string( string pAlt, float pIndex, string pSet ) Util_InsAltStringItem =
197 local float lPosition;
199 local string lLetter;
202 pSet = String_Zone( pSet );
204 pIndex = pIndex*2 + 2; // number of ' until item starts
205 lCount = lPosition = 0;
206 for( lLength = strlen( pAlt ) ; lPosition < lLength && lCount < pIndex ; lPosition = lPosition + 1 ) {
207 lLetter = substring( pAlt, lPosition, 1 );
211 else if( lLetter == "\\" )
212 lPosition = lPosition + 1;
215 if( lCount != pIndex )
218 lOut = String_Substring( pAlt, 0, lPosition );
219 pSet = String_Normal( Util_AltStringPrepare( String_Normal( pSet ) ) );
220 lOut = strcat( lOut, "'", pSet, "'", substring( pAlt, lPosition, lLength - lPosition ) );
222 return String_Set( pAlt, lOut );
225 string( string pAlt, float pIndex, string pSet ) Util_InsAltStringItem =
227 return String_Set( pAlt, altstr_ins( pAlt, pIndex, pSet ) );
233 Util_AltStringPrepare
237 string( string pString ) Util_AltStringPrepare =
239 local string lOut, lChar;
240 local float lPos, lLength;
242 pString = String_Zone( pString );
245 lLength = strlen( pString );
246 for( lPos = 0; lPos < lLength ; lPos = lPos + 1 ) {
247 lChar = substring( pString, lPos, 1 );
250 lOut = strcat( lOut, lChar );
253 String_Free( pString );
254 return String_Zone( lOut );
257 string( string pString ) Util_AltStringPrepare =
259 return String_Zone( altstr_prepare( pString ) );
268 string( string pAlt, string pPush ) Util_AltStringPush =
270 return String_Set( pAlt, strcat( "'", altstr_prepare( pPush ), "'", pAlt ) );
275 Util_AltStringPushBack
278 string( string pAlt, string pPush ) Util_AltStringPushBack =
280 return String_Set( pAlt, strcat( pAlt, "'", altstr_prepare( pPush ), "'" ) );
288 string( string pAlt ) Util_GetAltStringTop =
290 return Util_GetAltStringItem( pAlt, 0 );
298 string( string pAlt ) Util_AltStringPop =
300 local float lPos, lCount, lLength;
304 lLength = strlen( pAlt );
305 for( lPos = 0 ; lPos < lLength && lCount < 2 ; lPos++) {
306 lChar = substring( pAlt, lPos, 1 );
309 else if( lChar == "'" )
313 return String_Set( pAlt, substring( pAlt, lPos, lLength - lPos ) ); // no - 1 because this time we dont break after the '