String Indexing Example

String Indexing Example


This article presents an updated string indexing example.


This article contains an InstallScript sample that will show how you can index a string variable.

NOTE: The example will remove any leading zero characters in a given string variable.


A string variable is an array of Unicode characters with a null terminator. You can reference individual characters within a string by specifying the string name followed by an index value within square brackets. Note that the first character in a string is in position 0.

In the example below, the function BlankLeadingZeros() uses the string indexing technique to replace leading zeros in the string representation of a number with blank characters.
prototype BlankLeadingZeros(BYREF STRING); 
function BlankLeadingZeros(szString)
  INT iVal, iLength;
    iVal = 0; 
    iLength = StrLengthChars (szString); 

    while (iVal < iLength) && (szString[iVal] = "0") 
        szString[iVal] = " "; 

Additional Information

For more information on the data types used in this function, you can look at the online help document Data Types and Predefined Structures.
Was this article helpful? Yes No
No ratings
Version history
Revision #:
1 of 1
Last update:
‎Jul 09, 2018 10:09 PM
Updated by: