系统函数 strLib.getNextToken 在子串中搜索记号并将该记号复制至目标项。
标记是用定界字符分隔的字符串。例如,如果将空格(“ ”)和逗号(“,”)字符定义为定界符,则可以将字符串“CALL PROGRAM ARG1,ARG2,ARG3”分为 5 个记号“CALL”、“PROGRAM”、“ARG1”、“ARG2”和“ARG3”。
可以调用一连串的调用以检索子串中的每个记号,而不必重置 sourceSubstringIndex 和 sourceSubstringLength 的值,如后面的示例所示。
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
相关参考
EGL 库 StrLib