This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- String Indexing Example
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
String Indexing Example
String Indexing Example
Summary
This article presents an updated string indexing example.Synopsis
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.
Discussion
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; begin iVal = 0; iLength = StrLengthChars (szString); while (iVal < iLength) && (szString[iVal] = "0") szString[iVal] = " "; iVal++; endwhile; end; //-----------------------------------------------------------
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.
No ratings