Previous Topic: Val - Convert String to IntegerNext Topic: User-defined Functions


ValEx - Convert Decimal, Hexadecimal, or Octal String to Integer

Valid on UNIX and Windows

The ValEx function converts the input string, which specifies a decimal, a hexadecimal, or an octal number, to an integer.

This function has the format:

ValEx(str as String) as Integer
str

The string specifies a decimal, a hexadecimal, or an octal number, and can include a sign. The number specified is converted to an integer.

The function returns the integer value of the input string. If the string cannot be converted to a number, the function returns 0.

Example: ValEx function

Dim i As Integer
i = Val("2735")
Print("Val(""2735"")"+Str(i))
i=ValEx("2735")
Print("ValEx(2735")
Print("ValEx(""2735"")="+str(i))
i=ValEx("01414")
Print("ValEx(""01414"")="+str(i))
i=ValEx("0x1414")
Print("ValEx(""0x1414"")="+str(i))

Functions for Splitting Strings

To help parse information read from files or other sources, you can split strings into separate tokens or substrings using the following DMScript functions. A token is a substring separated from others by a delimiter, usually a space. You can quote tokens with single or double quotes.

SetTokenizerInput

The SetTokenizerInput function initializes the tokenizer with a string and defines the delimiters for splitting the string. This string and delimiters are valid for the rest of the script until you call the function with a different string or delimiter.

The function has the following format:

SetTokenizerInput(str as string, delimiters as string)

Input Parameters

This function has the following input parameters:

str

Specifies the input string that you want to split.

Note: You can specify only one input string at a time.

delimiters

Specifies the set of delimiters for splitting the string. By default, space characters are used as delimiters but you can specify any set of characters. For example, “.,/” tokenizes a list of substrings separated by a dot, comma or slash.

Return Values

None

GetToken

The GetToken function retrieves the next string token from the current input string set by SetTokenizerInput.

This function has the following format:

GetToken(token as string)as boolean

Example: GetToken

SetTokenizerInput("This is a test program", " ")
while GetToken(token)
   print token
wend

Input Parameters

This function has the following input parameters:

token

Specifies a string variable that holds the next token returned by the function.

Return Values

Returns True if it returned the next string token. It returns False if there are no more tokens left to retrieve from the current input string.

Output

This is a test program.