<< Click to Display Table of Contents >> Navigation: 3. Script Language > Mathematical and algorithmic operations > Mathematical and algorithmic operations |
MiniRobotLanguage (MRL)
VTH. Command
Variable To Hexadecimal
Intention
Convert a numeric value into the Hexadecimal-System, optional you can specify the length of the output string.
This very simple example
$$NUM=655345
VTH.$$NUM
DBP.$$NUM
Will give the result: "9FFF1"
In this example we say that we want the output to be formatted to 15 digits.
$$NUM=655345
VTH.$$NUM||15
DBP.$$NUM
ENR.
Therefore the result is "00000000009FFF1"
In both cases, we did not specify P2 (Target variable, therefore the result was placed in the source variable.
For details on how to prefix Hexadecimal, Octal or Binary numbers, see
3.5 Hexadezimal, Decimal and Binary and more
Syntax
VTH.P1[|P2][|P3]
Parameter Explanation
P1 - Variable containing any NUM
P2 - (optional) Variable for the result, if omitted result is been stored in Source variable.
P3 - (optional) optional, value that is used as a fix length of the output string.
Empty places are filled with "0"'s.
If you specify less digits then needed, the number will be clipped from the right side,
Example:
$$NUM=655345
VTH.$$NUM|$$TAR|2
will give you "F1" as result (instead of 9FFF1)
Example
'*****************************************************
' EXAMPLE 1:
'*****************************************************
' Binary to hexadecimal
$$NUM=&B10011111111111110001
VTH.$$NUM
DBP.$$NUM
' Hexadecimal to decimal (unsigned)
$$NUM=&H0$$NUM
VTN.$$NUM|$$TAR|6
DBP.$$TAR
ENR.
Remarks
-
Limitations:
-
See also:
• 3.5 Hexadezimal, Decimal and Binary and more
• CAL. - mathematical CALculation
• VAR. - Variable Set Value/Clear