<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > String Operations |
MiniRobotLanguage (MRL)
LEN. Command
LENgth of string
Intention
This command returns the length of a string in bytes. Usage is very intuitive:
: §§TXT=ABCDEFGHIJK
' Will return 11 on TOS
LEN.§§TXT
DBP.$$000
' Will return 11 in variable $$RES
LEN.§§TXT|$$RES
DBP.$$RES
Syntax
LEN.[P1][|P2]
Parameter Explanation
P1 - String to get Len from.
P2 - (optional) Variable to return the String-Len
All Parameters can be omitted. In each case the Source or Destination is TOS.
Example
'***********************************
' LEN.-Sample
'***********************************
: §§TXT=ABCDEFGHIJK
' Will return 11 on TOS
LEN.§§TXT
DBP.$$000
'
' Will return 11 in variable $$RES
LEN.§§TXT|$$RES
DBP.$$RES
END.
'***********************************
' LEN.-Test
'***********************************
VAR.$$TXT=12345678
PUV.$$TXT
DMP.4
' String from TOS, LEN-> TOS
LEN.
DMP.4
' Len->TOS
LEN.$$TXT
DMP.4
LEN.$$TXT|$$RET
PRT.$$RET
DMP.
END.
Remarks
-
Limitations:
The theoretical maximum length of a variable /text / string is 2 GB. In real life, it is less, because variables need string memory and that must not be fragmented. After all the maximum size of a variable on your system depends on the amount of RAM that is available, and it depends on how fragmented your memory is. Under normal circumstances several hundred MegaBytes should be no problem.
See also:
• 1.5.2 Working with Text-Strings
• VAR. - Variable Set Value/Clear
• IVS. / NVS. - If-Variable-String
• SBD. - String between Delimiter
• SBM. - String between Delimiter-Multiple