<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > String Operations |
MiniRobotLanguage (MRL)
STR.TO HEXASCI
String commands
Intention
To transfer binary data in written form, all "non-printable characters" like ASCII 12,13 and others need to be encoded in printable Form.
HEXASCII is a Format, which encodes ASC-Codes with their ASCII-value in Hexadecimal Format.
A -> 1E
B -> 30
etc.
STR.TO HEXASCI will convert the text or binary data that is contained in a variable, to the HEXASCII-Format. The result will be in the same variable or in a Target variable if given.
The command itself looks like this:
' $$SRC - Binary or Text-Data to convert to MIME
' $$TAR - MIME-Format Result
STR.TO HEXASCI|$$SRC|$$TAR
The Result looks somehow like you see below.
Its a Screenshot from the Examples below (see Examples-Section).
As you can see the HEXASCII encoded Binary is 530 bytes long, while the original size was 265 bytes. That is generally 200% the size of the original size.
Therefore its less efficient then MIME Encoding,
This is the reverse command to STR.FROM HEXASCI.
Syntax
STR.TO HEXASCI|P1[|P2]
Parameter Explanation
P1 - source variable. If P2 is missing then its also the destination variable
P2 - (optional) destination variable. If omitted the result is placed in the variable in P1.
Example
'*************************************
' STR.TO HEXASCI and
' STR.FROM HEXASCI
'*************************************
$$SRC=What happens with the + and / Characters in HEXASCII?
$$SRC=$$SRC$$SRC$$SRC$$SRC$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
STR.TO HEXASCI|$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
STR.FROM HEXASCI|$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
MBX.It works!
ENR.
'*************************************
' STR.TO HEXASCI and
' STR.FROM HEXASCI
'*************************************
$$SRC=What happens with the + and / Characters in HEXASCII?
$$SRC=$$SRC$$SRC$$SRC$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
STR.TO HEXASCI|$$SRC|$$TAR
LEN.$$TAR|$$LEN
PRT.($$LEN)->$$TAR
STR.FROM HEXASCI|$$TAR|$$ERG
LEN.$$ERG|$$LEN
PRT.($$LEN)->$$ERG
MBX.It works!
ENR.
Remarks
-
Limitations:
-
See also:
• 1.5.2 Working with Text-Strings
• VAR. - Variable Set Value/Clear
• IVS. / NVS. - If-Variable-String