StrToNum

InstallShield 2015 » InstallScript Language Reference

The StrToNum function converts a string to a number, much like the C function atol(). It inspects svString, starting with the character at position 0 and continuing through the string until it reaches the end of the string or encounters a character that is not in the range "0"..."9". (The first character in the string can be a plus or minus sign.)

Then one of the following processes occurs:

• If all of the characters in the string are in the range "0".."9", the number represented by the string is assigned to nvVar.
• If the string begins with one or more characters in the range "0".."9" but also contains one or more non-numeric characters, a number based on the characters to the left of the first non-numeric character is assigned to nvVar. For example, if szString is "-123ABC456", nvResult will be -123.
• If the first character in the string is not in the range "0".."9" and is not a plus or minus sign, the function fails.
• If the first character in the string is a plus or minus sign and the second character is not in the range "0".."9", the function fails.

Syntax

StrToNum ( nvVar, szString );

Parameters

StrToNum Parameters

Parameter

Description

nvVar

Returns the number created from the string in szString.

szString

Specifies the string to convert to a number. If the string corresponds to a number that is outside the range of allowed values for a number variable, this function gives unexpected results.

Return Values

StrToNum Return Values

Return Value

Description

0

Indicates that the function successfully converted the string into a numeric value.

< 0

Indicates that the function was unable to convert the string into a numeric value.

See Also