radix(
RADIX
,
VALUE
)

The radix( function converts a text item containing a number in a radix between 2 and 36 into a decimal number.


Parameters

This function has two parameters:

radix – is the base for the numbering system you are converting from. You may specify any base from 2 to 36, or you can specify the radix as binary (same as 2), octal (same as 8) or hex (short for hexadecimal, same as 16).

value – is a text item that contains the non-decimal number you want to convert.


Description

This function normally returns an integer that contains the decimal (base 10) number corresponding to the number in a radix between 2 and 36 which was input to the function. If there are more digits in an input number than can be converted to an integer within Panorama’s constraints, this function will return a raw binary data value instead of a number. This binary value may be of unlimited length. (Note: Since previous versions of Panorama did not have an explicit binary data type, earlier versions of this function returned the binary data in a text value. You may need to adjust your code accordingly.)

radix("hex","100") ☞ 256
radix(16,"100") ☞ 256
radix("binary","100") ☞ 4
radix("octal","100") ☞ 64
radix("h","4142434445464748494a4b4c4d4e") ☞ ABCDEFGHIJKLMN

Note: The final example converts the hex into binary data, which has then been automatically converted to text. This works fine for 7-bit ASCII, but will not work properly for 8-bit characters. See the binarytotext( amd texttobinary( functions to learn how to handle conversion of binary data to text using different encoding methods.


Error Messages

radix( function error: radix must be from 2–36, or ‘hex’, ‘octal’ or ‘binary’. – Choose a radix between base 2 and base 36.

radix( function error: input number contains illegal digit. – The input value contains an invalid digit. The range of valid digits varies depending on the radix being used. For base 2 (binary) only the digits 0 and 1 are valid, for octal values can be from 0–7, and for hexadecimal (base 16) a digit may be 0–9 or A-F.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now supports 64 bit values. If the specified radix is 16 (hex) and there are more than 16 digits supplied, the result will be a binary data value. Previous versions of Panorama would return binary data in a text value if there were more than 8 digits supplied. This function also now supports any base between 2 and 36, not just 2, 4, 8 and 16.