strToken (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

1.00 / 1.00.00


strToken will extract a sub-string within another string that contains a number of sub-strings - each separated by a "delimiter". The input number is the sub-string number to return.
Any leading or trailing spaces will be ignored.

 

Input:

str : STRING

String to search in.

 

delimiter : STRING

The delimiting string that separates the sub-strings in "str".

 

index : INT

The index number of the sub-string that should be returned.

 

Returns: STRING

The extracted sub-string from "str".

 

Declaration:

FUNCTION strToken : STRING;
VAR_INPUT
   str       : STRING;
   delimiter : STRING;
   index         : INT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
   result : STRING;
END_VAR;
 
PROGRAM test;
 
BEGIN
   ...
   result := strToken(str:="4711,4712,4713,4714", delimiter:=",", index:=2);
   // result will contain "4712" after the call
   ...
END;
 
END_PROGRAM;