Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter FiveGeneral Functions (continued)

TextToInteger Function

Overview

The TextToInteger function automatically detects and converts a string containing a hexadecimal, octal, or signed decimal number into an integer equivalent.

Syntax/Parameters

Syntax

long = TextToInteger ( string value );

Parameters

value

A string containing a hexadecimal, octal, or decimal number.

Return Value

Returns an long containing the integer equivalent of value or 0 on failure. Use the GetLastError function to retrieve error information.

Remarks

The TextToInteger function is the most general conversion tool for translating strings to integers. It does not require prior knowledge of what type of value (hexadecimal, octal, or decimal) the string contains. For decimal numbers, the source string can contain commas. String parsing will stop at the first non-digit. Because this function can return 0 as both a permissible value and as an error, use the GetLastError function to ensure the function succeeded.

Decimal numbers may lead with a ‘-’ character to indicate a negative number. Note that this function is not appropriate for converting decimal numbers with leading zeros since they will be interpreted as octal numbers which will result either in an erroneous return value or a syntax error. Use the DecimalToInteger function or trim the leading zeros, as required, if leading zeros are possible.

This function returns a 64-bit value. Depending on the source value parameter, if the return value is stored in an int type (or smaller), the value will be truncated if it exceeds the 32-bit integer size. Such a condition is considered a runtime warning which will be placed in the program log.

If the string parameter cannot be converted to an integer, the GetLastError function will return ERROR_SYNTAX.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic