GoFiler Legato Script Reference
Legato v 1.5b Application v 5.24b
|
Table of Contents | < < Previous | Next >> |
Chapter Five — General Functions (continued)
Overview
The HexToInteger function converts a string to a 64-bit qword.
Syntax/Parameters
Syntax
qword = HexToInteger ( string data | wstring data );
Parameters
data
A string or wstring in hexadecimal format with an optional leading ‘0x’ prefix.
Return Value
Returns a qword value representing the hex data or 0 on failure. Use the GetLastError function to retrieve error information.
Remarks
The string can be in plain hexadecimal format or lead with the prefix ‘0x’. It can also be a single 4-bit nybble to a full 64-bit value. It cannot contain any characters other than the hex value or prefix. Because 0x000000000000000 can be a valid return value, use the GetLastError function to determine if an error occurred (likely ERROR_SYNTAX or ERROR_OVERFLOW).
While the return value type is a qword, the result can be placed into any type with the recognition that the value may be truncated. Since hexadecimal representations of values are not signed, it is up to the script to manage negative numbers and sign extension. For example:
int i;
i1 = HexToInteger("0xFFFFFFFF");
MessageBox('I', "Result: %d", i);
Will not result in -1 but rather 4294967295. To extend the sign:
int i;
i = HexToInteger("0xFFFFFFFF");
if ((i & 0x80000000) != 0) {
i |= 0xFFFFFFFF00000000;
}
MessageBox('I', "Result: %d", i);
This assumes a 32-bit signed value is expected. When the 32nd bit is set, the sign is extended. Note that Legato uses 64-bit math internally and if a signed value is placed into a smaller container, i.e. long to int, the extra sign bits are stripped. Therefore, if a long type is used, this procedure is not necessary. Further, if the hex value is not expected to be signed, the procedure is not required.
Related Functions
Platform Support
Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL
Legato IDE, Legato Basic
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.