Topic: DMD0173

STRTRUNC - Set String Length


The Set String Length (STRTRUNC) instruction will set the length of a String to the designated value.

 

 

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.

 

String - the String to set the length of. This can be any writable String element.

 

Length - designates the length (in characters) to make the String. This can be any readable numeric location, or a constant value between 0 and the maximum length of the String (<string>.MaxLen).

 

If a length of 0 is specified this will set the length to 0.

 

If a negative length is specified, the length will be set to the maximum length of the String, and a system warning message will be generated (this warning can be viewed at System Information-> System Status tab -> Warning Messages box -> "Buffer Overflow").

 

If the specified length is longer than the current length of the String (<string>.Length), the length will be set to specified value, and the current string will be padded with NULL characters (0x00), not spaces.

 

If the specified length is longer than the maximum length of the String (<string>.MaxLen), the length will be set to the maximum length of the String,  the current string will be padded with NULL characters (0x00), and a system warning message will be generated (this warning can be viewed at System Information-> System Status tab -> Warning Messages box -> "Buffer Overflow").

 


Status Display:

The Status display of the Set String Length Integer 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.

 

Before executing the STRTRUNC instruction:

 

After Executing the STRTRUNC instruction:


See Also:

 


Related Topics:

String Functions Overview

 

String Scripting Language Reference

 


Rung Example: