The system function StrLib.getNextToken searches a substring for a token and copies that token to a target item.
Tokens are strings separated by delimiter characters. For example, if the characters space (" ") and comma (",") are defined as delimiters, the string "CALL PROGRAM ARG1,ARG2,ARG3" can be broken down into the five tokens "CALL", "PROGRAM", "ARG1", "ARG2", and "ARG3".
StrLib.getNextToken( target VagText inOut, source VagText in, sourceSubstringIndex INT inOut, sourceSubstringLength INT inOut, characterDelimiter VagText in) returns (result INT)
You can invoke a sequence of calls to retrieve each token in a substring without resetting the values for sourceSubstringIndex and sourceSubstringLength, as shown in a later example.
Function myFunction() myVar myStructurePart; myRecord myRecordPart; i = 1; myVar.mySourceSubstringIndex = 1; myVar.mySourceSubstringLength = 29; while (myVar.mySourceSubstringLength > 0) myVar.myResult = StrLib.getNextToken( myVar.myTarget[i], "CALL PROGRAM arg1, arg2, arg3", myVar.mySourceSubstringIndex, myVar.mySourceSubstringLength, " ," ); if (myVar.myResult > 0) myRecord.outToken = myVar.myTarget[i]; add myRecord; set myRecord empty; i = i + 1; end end end Record myStructurePart 01 myTarget CHAR(80)[5]; 01 mySource CHAR(80); 01 myResult myBinPart; 01 mySourceSubstringIndex INT; 01 mySourceSubstringLength BIN(9,0); 01 i myBinPart; end Record myRecordPart serialRecord: fileName="Output" end 01 outToken CHAR(80); end
Related concepts
Syntax diagram for EGL functions
Related reference
EGL library StrLib