Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ InTouch HMI

StringTrim() Function

  • Last UpdatedJul 23, 2024
  • 1 minute read

Trim leading and trailing spaces (blanks) from strings. You can use this to remove unwanted spaces from a string, for example after a user input.

Syntax

result = StringTrim (string, trimtype)

Parameters

string

A literal text, message tagname, or string expression.

trimtype

A literal value, analog tagname, or numeric expression that determines which spaces to remove:

  • 1 = Leading spaces.

  • 2 = Trailing spaces.

  • 3 = Leading and trailing spaces.

Remarks

This function removes all leading and trailing white spaces from a string. White spaces are spaces (ASCII 0x20) and control characters in the range from ASCII 0x09 to 0x0D.

Example(s)

To remove all spaces in a message tag, mtag, with an action script, use the following script:

DIM i AS INTEGER;

DIM tmp AS MESSAGE;

mtag = StringTrim(mtag,3); {mtag is trimmed}

FOR i = 1 TO StringLen(mtag) {run variable i over the characters of mtag}

IF StringMid(mtag, i, 1)<>" " THEN {i-th character is not space} tmp = tmp + StringMid(mtag, i, 1); {

add that character to tmp}

ENDIF;

NEXT;

mtag = tmp; {pass tmp back to mtag}.

Other examples:

StringTrim(" Joe ",1) returns "Joe ".

StringTrim(" Joe ",2) returns " Joe".

This script removes all spaces from the left and the right of the mtag value:

mtag = StringTrim(mtag,3)

In This Topic
TitleResults for “How to create a CRG?”Also Available in