Topic: DMD0170

STRPRINT - Print to String


The Print to String (STRPRINT) instruction is used to put formatted data into a String. The formatting is specified using a string script. The string script consists of any combination of the following:

 

  • the contents of a user-defined string
     

  • a string literal
     

  • the result of a string function
     

  • controller memory elements

 

 

Parameters:

Note: Use the F9 key (Element Browser) or Down-Arrow key (Auto-Complete) at any time to see a complete list of the memory locations that are valid in the current field of the instruction.

 

Print to - the destination String. This can be any writable String Element.

 

Append to String - controls how any existing data in the destination String will be handled

 

  • if not checked (the default) the Print to String will be overwritten with data from the string script.
     

  • if checked the data in the Print to String will remain intact and the output of the string script will be appended to it.

    Note:
    If the resulting String exceeds the maximum length of the destination String, the destination String will be truncated to its maximum length and a 'Buffer overflow' warning will be generated.

 

Automatically insert space after each term - will insert a space between the terms in the script when the instruction is stored in the Do-more controller. This is very useful when the Text Field contains only a list of elements that would otherwise require a manually entered space character to separate the items.

 

For example, assume that D0 contains the value 1234, D1 contains 5678, and D2 contains 9012.

 

If the Print Script contains "D0 D1 D2" and the 'Automatically insert space' is checked the output string will be "1234 5678 9012".

 

If the Print Script contains "D0 D1 D2" and the 'Automatically insert space' is NOT checked the output string will be "123456789012".

 

You could get the same result by manually inserting space characters in the Text Field like this: D0 " " D1 " " D2

 


Print Script - contains the list of elements, strings, string literals and string functions to output to the Print to String. There can be up to 1023 characters of data in the Print Script. The data can be any combination of the following:
 

  • string literal which can contain both printable and control character escape sequences

  • any String element

  • data formatting functions

  • string selection function

  • raw (binary) data

 

For a complete description of the available data options provided by the scripting language for use in the Print Script, see the Help reference for the String Scripting Language.

 


Status Display:

The Status display of the Print to String (STRPRINT) instruction will only display as many of the characters of the String as will fit within the borders of the instruction, typically this is about 50 characters.

 

The gray triangle at the right end of an input leg indicates the input is edge triggered.


See Also:

 


Related Topics:

String Functions Overview

 

String Scripting Language Reference

 

PACKETOUT - Output Data to Packet Device

 

STREAMOUT - Stream Out Data to Device

 


Rung Example: