hpw
Full Member
Posts: 30
|
Post by hpw on Oct 24, 2020 7:00:33 GMT
Hello Steve,
Can you consider to add a command STRING PARSE to custom variables?
1 | RUN ACTION | STRING PARSE | Sourcestr1;Sourcestr2;Sourcestr3 | ; | %variablename%
1 | RUN ACTION | STRING PARSE | %stringsource% | ; | %variablename%
Reads: Parse the source-string using the delimter-char into custom variables:
%variablename1%
%variablename2%
%variablename3%
So you get an string array.
Regards Hans-Peter
|
|
|
Post by Steve on Oct 24, 2020 7:04:55 GMT
Yes. More with string manipulation the better.
Thanks for the suggestion.
|
|
|
Post by cyberchipz on Oct 14, 2021 19:30:14 GMT
Well, if I may suggest then: LEN, LEFT, MID and RIGHT to the suggestion? While you're at it. You'll use those to parse, right?
* | LEN Function 1 | RUN ACTION | STRING LEN | STRING TO INTEGER VARIABLE | %INTRESULT%::LEN::%SOURCESTR%
* | LEFT Function 1 | RUN ACTION | STRING LEFT | STRING TO STRING VARIABLE | %RESULT%::LEFT::%SOURCESTR%::%LEFTNUMBER%
* | RIGHT Function 1 | RUN ACTION | STRING RIGHT | STRING TO STRING VARIABLE | %RESULT%::RIGHT::%SOURCESTR%::%RIGHTNUMBER%
* | MID Function 1 | RUN ACTION | STRING MID | STRING TO STRING VARIABLE | %RESULT%::MID::%SOURCESTR%::%STARTNUMBER%::%LENGTH%
THEN, With this routine you can parse any two strings... USING A FOR NEXT LOOP :-) (PSEUDO CODE HERE) I didn't want to write out whole code for none existing code. ;-) (And, I don't use FOR/NEXT very OFTEN) Since many people may have never written this code... here's the short form of it in a PSUEDO CODE using LEN and MID.
*CALL SUBFUNCTION HERE with %SOURCESTR% and %SEARCHSTR DEFINED (AND %RETURNLINE% and Line Label ReturnHERE)
%OURCESTR%::THIS IS A TEST OF SOME CODE %SEARHSTR::SOME * | NOTE Now call the function 23 | RUN ACTION | DEFINE STRING VARIABLE | %RETURNLINE%::ReturnHERE 23 | RUN ACTION | GOTO MACRO LINE | FunctionINSTR
* | NOTE: And come back here when done. * | ReturnHERE * | Note: IF %PRESENT% is FALSE, not found, if TRUE Found it. 23 | RUN ACTION | STOP
* | FunctionINSTR * | Get LEN of %SOURCESTR% = %SRC_LENGTH% & %SEARHSTR% = %STR_LENGTH%
1 | RUN ACTION | STRING LEN | STRING TO INTEGER VARIABLE | %INTRESULT%::LEN::%SOURCESTR%
2 | RUN ACTION | STRING LEN | STRING TO INTEGER VARIABLE | %INTRESULT%::LEN::%SEARCHSTR%
FOR %I% = 1 TO %LENGTH%::(%SRC_LENGTH%-%STR_LENGTH%)
3 | RUN ACTION | STRING MID | STRING TO STRING VARIABLE | %STRPIECE%::MID::%SOURCESTR%::%I%::%LENGTH%
4 | IF | STRING VARIABLE | %RESULT% | IS | %SEARCSTR% | DEFINE BOOLEAN VARIABLE | %RESULT%::TRUE (NOTE: IF TRUE %RESULT% is %SEARCHSTR at %I% in %SOURCESTR%
5 | IF | BOOLEAN VARIABLE | %RESULT% | IS TRUE | GOTO MACRO LINE | FoundIt
NEXT %I%
6 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %RESULT%::FALSE
FoundIt 7 | RUN ACTION | GOTO MACRO LINE | %RETURNLINE *| ENDINSTR
Note: IF %PRESENT% is FALSE, not found, if TRUE Found it.
one can parse until
18 | IF | STRING VARIABLE | %RESULT% | IS | %SEARCHSTR% | DEFINE BOOLEAN VARIABLE | GOTO %PRESENT%::TRUE
|
|