strRemoveSpaces (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


strRemoveSpaces will remove leading and trailing spaces in a string. It is optional if the function should remove the leading, trailing, or both types of spaces in a string.

 

Note that the returned string is a dynamic string.

 

Input:

str : STRING

String that is to be extracted from.

 

leading : BOOL Default TRUE

TRUE if leading spaces should be removed.

 

trailing : BOOL Default TRUE

TRUE if trailing spaces should be removed.

 

Returns: STRING

The extracted string.

 

Declaration:

FUNCTION strRemoveSpaces : STRING;
VAR_INPUT
  str     : STRING;
  leading : BOOL := TRUE;
  trailing : BOOL := TRUE;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  result : STRING;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
result := strRemoveSpaces(str:="   hello world  ", trailing:=FALSE);
  // result will contain "hello world  " after the call, as only leading spaces are removed
  ...
END;
 
END_PROGRAM;