Topic: DMD0307

Help File Version: 2.10.0.636

STRPUTB - Put Bytes Into a String


The Put Bytes Into a String (STRPUTB) instruction will copy bytes of data from memory locations in the controller and place them in the specified String.

 

The primary use of this instruction - and its companion instruction Get Bytes Out of a String (STRGETB) - 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 Strings containing ASCII text; working with Strings 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 Strings containing ASCII data.

 


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.

 

Put Into String - designates the String to receive the bytes of data. This can be any of the system-defined Short Strings (SS0 - SS127), or system-defined Long Strings (SL0 - SL63), or any user-defined Strings.

 

Start at Index - designates the location in the String to begin placing 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.

 

Length in Bytes - designates the total number of bytes of data to copy and place in 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.

 

From Starting Element - designates the first location in the controller where the bytes of data are copied from. This can be any readable numeric location.

Create Byte Buffer... - many communication protocols are constructed using Bytes of data, but the Do-more controller does NOT have a preconfigured block of Unsigned Bytes. If a Byte buffer is needed, clicking Create Byte Buffer will open the Create Unsigned Byte Buffer Block dialog where one can be created.

 

Data Block Name (1 to 16 letters)- Block names must be unique, and consist of 1 to 16 characters (A-Z, a-z; no numbers, no spaces). The default name STRPUTBBuff can be changed if desired.

 

Number of Elements - specifies the number of bytes in the data block. The data blocks must be created on a DWord (4-byte) boundary. The maximum number of Bytes that can be received from a single packet is 1024.

 

Unsigned Byte Data Block Range - displays the first and last element of the block that will be created based on the current entries for Data Block Name and Number of Elements.

 

Data Type - the data block will consist of Unsigned Bytes.

 

Make Data Block Retentive (retain values after power loss) - a data block marked as retentive will hold its state through a power cycle or a Program-to-Run mode transition. The status of memory NOT marked as retentive will be cleared at power up and during a Program-to-Run mode transition.

 

Clicking OK will automatically select the newly created data block as the From Starting Element location.

 


Status Display:

 

The Status display of the Put Bytes Into a String instruction will only display as many of the characters of the Put Into 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

 

STRCLEAR - Clear Strings

 

STRCMP - String Compare

 

STRCOPY - Copy String

 

STRCOPYR - Copy a Range of Strings



STRDELETE - Delete Substring

 

STRFIND - Find within String

 

STRINSERT - Insert Substring

 

STRPRINT - Print to String

 

STRSUB - Get Substring

 

STRTRIM - Trim Whitespace

 

STRTRUNC - Truncate String

 


String Functions Overview

 

String Scripting Language Reference

 


Rung Example: