13 string functions of the INSTALLSHIELD internal library function
String functions provide a function of processing string variables and text. The string function is similar to the standard C language function. The return value also follows the rules of the C language.
Copybytes
Copy the number of specified bytes to the other from a string.
Getdir
Remove the drive ID from a path name or fully qualified file name.
GetDisk
Retrieve the disk drive ID from a path name or fully qualified file name.
Numtostr
Convert a number to a string.
Parsepath
Retrieve drives, paths, file names, or extensions from a path.
Strcompare
A string and another comparison.
Strfind
Find a string in another string.
StrgetToKens
Get a token from a string based on the specified delimiter.
Strlength
Returns the number of bytes in a string.
StrlengthChars
Returns the number of characters in a string.
StrremoveLastslash
Delete the last backslash in a path string.
Strsub
Returns a substring from a string.
STRTOLOWER
All alphanumeric characters in the conversion string are lowercase.
Strtonum
The conversion string is a number.
Strtoupper
All alphanumeric characters in the conversion string are uppercase.
13.1 Copybytes
Syntax: Copybytes (SvDest, NindexDest, SVSRC, NINDEXSRC, NCOUNT);
Description: The CopyBytes function copys the specified number of bytes from a string to another string. You can specify the offset subscript in the source and target string.
parameter:
svdest
Specify the target string.
NindexDest
Specifies the offset subscript (start point) in the target string, starting from this location. The first byte of the string is in position 0.
SVSRC
Specify the source string. Do not pass a string of automatic adjustment of a size greater than 256 characters. It should be made with an explicit size statement string. Nindexsrc
Specify the offset subscript (start point) of the source string, start copying these bytes from this location. The first byte of the string is in position 0.
NCOUNT
Specify the total number of bytes you want to copy from SVSRC to SVDest. This value must not be greater than the size of SVSRC-1. For example, if the SVSRC is declared as a size 512 (gives it the maximum string length 511), the value passed to the NCOUNT must be 511 or less.
return value:
0: CopyBytes successfully copies the specified number of bytes to another from a string.
<0: CopyBytes is not copied to these bytes.
annotation:
Copybytes is useful when you work in binary files.
13.2 getDir
Grammar: getdir (Szpath, SVDIR);
Note: The getDir function removes the drive indicator from the fully qualified path or file name specified by Szpath and returns the 余 参 s s s 路 s回. The path name must contain a drive indicator. It can be a UNC path.
In the following example, the fully qualified path C: / windows returns to / Windows in SVDIR.
GetDir ("C: // Windows", SVDIR);
In the next example, UNC Path // TheServer / TheSharedDevice / Program returns to / programs in SVDIR.
GetDir ("THSERVER // THESHAREDDEVICE // Programs", SVDIR;
parameter:
Szpath
Specifies the path to contain a drive indicator.
svdir
Returns the path without the driver indicator. If SZPATH is a UNC path, getDir will return the path where the server name and the shared device name are not. return value:
0: Indicates that the function successfully returns the path name without the driver indicator.
<0: Indicates that the function failed to return the path name without the driver indicator.
13.3 GetDisk
Grammar: getDisk (Szpath, SVDisk);
Note: The getDisk function is quarantined from the full-qualified path or file name specified by SZPath.
parameter:
Szpath
Specifies a fully qualified path or file name that contains a drive indicator. GetDisk will fail if it does not contain a drive indicator. The value passed to SZPath can be a UNC path.
svdisk
Returns the drive indicator (including a colon). If SZPATH is a UNC path, getDisk returns the server name and shared device name in "// Server / Shared Device" format.
return value:
0: Indicates that the function successfully returns the drive indicator.
<0: Indicates that the function failed to return the drive indicator.
13.4 NumTostr
Syntax: NumTostr (svstring, nvalue);
Description: The NumTostr function converts a number into a string.
parameter:
Svstring
Returns the NVALUE string equation (equivalent string).
Nvalue
Specifies the numbers to be converted to a string.
return value:
0: Indicates that the function is successfully converted to a string.
<0: Indicates that the function failed to convert numbers to a string.
13.5 PaSepath
Syntax: parsepath (svreturnstring, szpath, noperation);
Description: The parsepath function retrieves a specified portion where the path is present. The function can work in any valid path, including short path, long path, and UNC path, which may contain or do not include a specific file name. Below is some path samples that can be analyzed with this function:
/Path1/path2/filename.exe
Filename
Filename.exe
/ Path1 / Path2 / FileName
D:
D: /
// Server name / share name / share Directory
Any other legitimate DOS path.
parameter:
Svreturnstring
Returns the path in the parameter szpath by the part specified by the parameter NOPERATION.
Szpath
Specifies the path to be analyzed. When specifying a path that does not contain a file name, you must add a backslash at the end of the path before passing it to PARSEPath; otherwise the last part of the path will be interpreted as a file name.
NOPERATION
Specifies which element of the return path. One of the following predefined constants in this parameter location:
Directory: Indicates that the disk drive character and file name must be removed in the SVRETURNSTRING returns. When this option is used in a UNC path, PARSEPATH returns a path without a server and a shared device name, and there is no file name (may be specified). For example, UNC path //THESERVER/TheSharedDevice/theapp/thefile.exe returns / theApp /.
Disk: Indicates that the disk drive indicator must be returned in SVRETURNSTRING (with a colon after the drive character). When this option is used in a UNC path, PARSEPATH returns the server name and shared device name. For example, UNC path //TheSHESHAREDDEVICE/THEAPP/TheFile.exe returns // theServer / TheSharedDevice at Svreturnstring. EXTENSION_ONLY: Indicates that the file extension must be returned in Svreturnstring. It does not include a period.
FileName: Indicates that the full file name that must be returned in Svreturnstring (that is, the file extension) is included.
FileName_only: Indicates that only the file name (that is, does not include its file extension).
PATH: Indicates that the file name must be removed in the SVRETURNSTRING returns. This option is different from Directory because the drive indicator (if specified in SZPath) is included in the return path. When SZPATH specifies a UNC path, the server name and the shared device name are included in the return path. For example, UNC path //THESHESHAREDDEVICE/THEAPP/TheFile.exe returns to // theServer / theSharedDevice / theApp /.
return value:
0: Indicates that the function successfully analyzes the path string.
<0: Indicates that the function failed to analyze the path string.
13.6 Strcompare
Syntax: Strcompare (Szstringa, Szstringb);
Note: The strCompare function compares two strings. Compare unclear cases.
parameter:
Szstringa
Specifies the first string to be compared.
Szstringb
Specifies the second string to compare.
return value:
<0: Indicates that the value of the SzstringA string is less than the value of the string of szstringb.
= 0: Indicates that two strings are equal.
> 0: Indicates that the value of the string of SzstringA is greater than the value of the string of szstringb.
annotation:
· The strCompare function compares two strings, by checking the first character in each string, then pushing the second character in each string until it finds an unequal character or arriving in characters. Skewer end.
· Language drivers you choose to determine which string large or string is equal. If you don't use a language driver, Windows uses an internal function. For a double-byte character set (DBCS) version of Windows, this function can compare two DBCS strings.
13.7 Strfind
Syntax: strfind (szstring, szfindme);
Note: The strfind function determines whether the string passed to the parameter SZFINDME is passed to the string of the parameter szstring. If SZFINDME is found in SzString, strfind returns the location of the first character of Szfindme in szstring. Note that the location of the first character in szstring is 0. This function is not case sensitive and can only be used to find SZFindme first appear in szstring.
In the example below, strfind will return a value 13.
NStartPOS = Strfind ("scripting is fun", "fun");
If only one TRUE or FALSE is required to indicate whether a string contains another string, (i.e., if the position of the substrings is not important), use the string to find the operator (%), as shown below : IF (Szstring% Szfindme) Then ...
In the Boolean expression that can be parsed in the IF statement, you can use only string to find operators. You can't use it in the REPEAT statement or the While statement.
parameter:
Szstring
Specify the string to look up.
Szfindme
Specifies the string to find in szstring.
return value:
X: If szstring contains SZFINDME, X is the value position of the first character in SZFINDME. The first character in szstring is in position 0.
<0: Indicates that szstring does not contain SZFineMe.
13.8 strGetToKens
Syntax: strGetToKens (ListID, Szstring, SzdelimiterSet);
Description: The strGetToKens function is extracted from the string (called token) specified by Szstring and places them into the list specified by the listID. Subtrings in SzString must be separated by one or more characters specified by szdelimiterSet (mutually separated).
For example, if you call strGetToKens, strings "one; two; three;"; "as the second parameter," One "," One "," Two "," Three "," FOUR " And "FIVE" five strings will be returned to ListID. Use list functions such as ListGetFirstString and ListGetNextString to access each token in the list.
If the first character in szstring matches one of the szdelimiters, an empty string will be inserted into the first element of the list. Similarly, if the last character in szstring matches one of the characters in the szdelimiters, an empty string will be inserted into the last element of the list.
parameter:
ListID
Returns a list of tokens. A list of strings identified by the ListID must have been initialized by calling the ListCreate.
Szstring
Specifies the string to be analyzed.
Szdelimiterset
Specify a collection of one or more separators. Each separator is a character (1 byte). If you pass an empty string in this parameter, the function is looking for empty characters as a separator. Useful when you use the getProfstring function.
When a space is specified as a separator, strGetToKens processes a continuous space for a separate separator.
return value:
0: Indicates that the function is successfully divided by the string and insert the token into the specified list.
<0: Indicates that the function is not separated by string and inserts the token into the specified list.
13.9 Strlength
Syntax: Strlength (szstring);
Description: Use the Strlength function to get the number of bytes in a string. To determine the number of characters in a string, use StrlengthChars.
parameter:
Szstring
Specifies a string to determine its size.
return value:
X: X is the number of bytes in the string.
<0: Indicates that the function cannot determine the number of bytes in the string.
13.10 StrlengthChars
Syntax: StrlengthChars (Szstring);
Note: Use the strLengthChars function to get the number of characters in a string. To determine the number of bytes in a string, use Strlength.
parameter:
Szstring
Specifies a string to determine its size.
return value:
X: X is the number of characters in the string.
<0: Indicates that the function does not determine the number of characters in the string.
13.11 StrremoveLastslash
Syntax: StrremoveLastslash (SVPATH);
Description: The strremovelastslash function removes the end backslash from a path description.
parameter:
svpath
Specify a string, its value must be a path description; returns the path without ending backslash. Note that if the path does not contain a backslash, it is returned without modification.
return value:
0: Indicates that the function successfully removes the end anti-slash or path does not contain an end backslash.
<0: Indicates that the function failed to delete the end backslash.
annotation:
· StrremoveLastslash provides a convenient way to cut the path returned by askPATH or PARSEPATH. Because its purpose is to generate a valid path name, strremovelastslash does not remove the backslash from a root instructions, such as "A: /" or "C: /"; doing this to convert a valid path name to a drive description (Identification). Do you need to cut off a backslash of a path in any case, refer to the following script segment.
AskPATH (",", ", SVPATH);
IF (Strlength (SVPATH) = 3)
&& (svpath [1] = ":")
&& (svpath [2] = "
// ") THEN
svTempstring = svpath;
STRSUB (SVPATH, SVTEMPSTRING, 0, 2);
Else
StrremoveLastslash (SVPATH);
Endif;
13.12 STRSUB
Syntax: strsub (Svsubstr, Szstring, NStart, NLENGTH);
Description: The strsub function copys the part of the string specified by szstring, starting from the location specified by NStart. Parameter NLENGTH Specifies the number of characters to copy.
parameter:
Svsubstr
Returns a substring from szstring copies.
Szstring
Specifies the string to copy the subtrings from the middle.
NStart
Specifies the offset in a szstring to identify the first character to be copied. Note that the location of the first character in szstring is 0. If the value passes to NSTART is equal to or greater than the length of szstring, an empty string is returned in SvSubstr.
NLENGTH
Specifies the number of characters from szstring copies. If this value specifies more characters between NSTART and SZString end, all characters ending from NStart to string from NSTART.
return value:
X: X is equal to the number of characters of SVSUBSTR.
13.13 STRTOLOWER
Syntax: STRTOLOWER (SVTARGET, SZSOURES);
Note: The Strt Lower function converts all letters in a string to lowercase. This function does not affect non-alphabetic characters.
parameter:
svtarget
Returns the string in SzSource, all characters have been converted to lowercase.
Szsource
Specify strings to be converted to lowercase characters.
return value:
0: Indicates that the function successfully modified the case of the string.
<0: Indicates that the function failed to modify the case of the string. 13.14 Strtonum
Syntax: Strtonum (NVVAR, Szstring);
Description: The Strtonum function converts a string into a number and is similar to the C function atol (). It checks svstring, starting from the character 0 characters, continues until it reaches the string or encounters a character within "0". "9". (The first character in the string may be a plus sign or minus number.) The following processing will appear:
If all characters in the string are in the "0". "9" range, the numbers represented by the string are assigned to NVVAR.
If the string starts in one or more "0" .. "9" but also contains one or more non-digital characters, all characters that appear on the left side of the first non-digital character will be assigned to NVVAR. . For example, if szstring is "-123ABC456", NVRESULT will be -123.
If the first character of the string is not in "0" .. "9" range and is not a plus sign or minus number, the function fails.
If the first character of the string is a plus or minus number, and the second character is not in "0" .. "9" range, the function fails.
parameter:
nvvar
Returns the numbers generated from Szstring string.
Szstring
Specifies a string to be converted to a number.
return value:
0: Indicates that the function successfully converts the string into a numeric value.
<0: Indicates that the function failed to convert a string into a numeric value.
13.15 Strtoupper
Syntax: StrtOUPPER (SVTARGET, SZSOURCE);
Description: The Strtoupper function converts all letters in a string to uppercase. This function does not affect non-alphabetic characters.
parameter:
svtarget
Returns the string in szsource, all characters have been converted to uppercase.
Szsource
Specify strings to be converted to uppercase characters.
return value:
0: Indicates that the function successfully modified the case of the string.
<0: Indicates that the function failed to modify the case of the string.