strGetStrings (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


strGetStrings is similar to strGetValues. It will try to extract up to 4 strings from a string. It uses the same syntax for the format string as strFormat. strGetStrings is not case sensitive !

 

 

Input:

str : STRING

String that strGetValues will extract values from

 

format : STRING

Format string, can contain up to 4 parameter references written as

\1, \2, \3, and \4. Each of these will extract the value at that position and place it in v1, v2, v3, or v4.

Please note that a specific number can only be referenced one time in the format string.

 

Output:

match: BOOL

This will be TRUE if a match was found and the number of strings was extracted successfully.

 

v1: STRING

The extracted string at {1} from str.

 

v2: STRING

The extracted string at {2} from str.

 

v3: STRING

The extracted string at {3} from str.

 

v4: STRING

The extracted string at {4} from str.

 

Declaration:

FUNCTION_BLOCK strGetStrings;
VAR_INPUT
  str   : STRING;
  format : STRING;
END_VAR;
VAR_OUTPUT
  match : BOOL;
  v1     : STRING;
  v2     : STRING;
  v3     : STRING;
  v4     : STRING;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  extract     : strGetStrings;
  inputstring : STRING;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
  inputstring:="The north valve is closed";
 extract(str:=inputstring, format:="The \1 valve is \2");
  IF extract.match THEN
    // extract.v1 contains "north", extract.v2 contains "closed"
     ...
  END_IF;
END;
 
END_PROGRAM;