Topic: DMD0306 STRGETB - Get Bytes Out of a String |
|
The Get Bytes Out of a String (STRGETB) instruction will extract bytes of data from the specified String and place them in the specified memory block. The primary use of this instruction - and its companion instruction Put Bytes Into a String (STRPUTB) - is in creating protocol drivers, where the data in the String is not ASCII text but consists of 16-bit, or 32-bit integers, or floating point numbers.
Note: this instruction is NOT intended to operate on data buffers containing ASCII text; working with data buffers that contain ASCII text is better handled through the STRCMP, STRFIND, STRSUB, STRDELETE, STRINSERT, STRCASE,STRCLEAR, STRTRIM, STRTRUNC instructions that are purpose-built to handle ASCII data.
Note: If the data in the String is an ASCII text representation of integer or floating point numbers, the correct instruction to use for handling that data is the Convert String to Integer (STR2INT) or Convert String to Real (STR2REAL) respectively.
|
|
Element References:Note: Use the F9 key or click the 'three dot box' at the right edge of the parameter field to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.
Get out of String - specifies the String which contains the bytes of data to copy. This can be any of the system-defined Short Strings, system-defined Long Strings, or any user-defined String.
Start at Index - specifies the first location in the String where to begin copying the bytes of data. This can be any readable numeric location or a constant value from 0 to the maximum number of characters in the String.
Note: if the Index value is greater than the number of bytes of data in the String, the following warning message will be generated: "Attempted string operation was longer than target string and was truncated in STRGETB at <code-block>@<address>"
Length in Bytes - specifies the total number of bytes of data to copy from the String. This can be any readable numeric location or a constant value from 1 to the maximum number of bytes available in the String.
Note: if the Length in Bytes value is greater than the number of bytes of data in the String, the following warning message will be generated: "Attempted string operation was longer than target string and was truncated in STRGETB at <code-block>@<address>"
Into Starting Element - specifies the beginning location of the memory block to place the bytes of data read from the String. This can be any writable numeric location.
|
|
Status Display:
The Status display of the Get Bytes Out of a String instruction will only display as many of the characters of the Get out of String as will fit within the borders of the instruction, typically this is about 50 characters.
|
|
See Also:STRGETB - Get Bytes Out of a String
STRPUTB - Put Bytes Into a String
|
|
Related Topics:STR2REAL - Convert String to Real
STR2INT - Convert String to Integer
STRCASE - Convert String to UPPER / lower Case
STRCOPYR - Copy a Range of Strings
String Scripting Language Reference
|
|
Rung Example:
|
|