rexx parse for dummies


Topic author
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 822
Joined: Wed Sep 11, 2013 3:57 pm
Been thanked: 69 times

rexx parse for dummies

Postby enrico-sorichetti » Sun Oct 09, 2016 4:41 pm



cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)


Topic author
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 822
Joined: Wed Sep 11, 2013 3:57 pm
Been thanked: 69 times

Re: rexx parse for dummies

Postby enrico-sorichetti » Wed Oct 12, 2016 4:43 pm

I went over the presentation and running the Parse examples I got different results

the script

Code: Select all

#! /usr/bin/env rexx

Trace "O"
signal on novalue name novalue

str = " We have met the enemy, and he is us. "

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str v1 v2 v3 v4 v5 v6 v7 v8
say "Word Parsing (0)"
say "Parse Var str v1 v2 v3 v4 v5 v6 v7 v8"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str v1 v2 v3 . v4 v5 . v6 v7 v8
say "Word Parsing (1)"
say "Parse Var str v1 v2 v3 . v4 v5 . v6 v7 v8"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str v1 v2 v3 . v4 v5 v6
say "Word Parsing (2)"
say "Parse Var str v1 v2 v3 . v4 v5 v6"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str v1
say "Word Parsing (3)"
say "Parse Var str v1"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6
say "Absolute Position Patterns (1)"
say "Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str 1 v1 +9 v2 v3 v4 +7 v5 +8 v6
say "Relative Position Patterns (1)"
say "Parse Var str 1 v1 +9 v2 v3 v4 +7 v5 +8 v6"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6 1 v7 v8
say "Absolute Position Patterns (2)"
say "Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6 1 v7 v8"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str 1 v1 =25 v2 =15 . v3 =19 v4 =5 v5
say "Absolute Position Patterns (3)"
say "Parse Var str 1 v1 =25 v2 =15 . v3 =19 v4 =5 v5"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str 1 v1 +24 v2 -10 . v3 +4 v4 -14 v5
say "Relative Position Patterns (3)"
say "Parse Var str 1 v1 +24 v2 -10 . v3 +4 v4 -14 v5"
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
Parse Var str =2 v1 +2,
              =5 v2 +4 ,
             =11 v3 +3 ,
             =15 v4 +3 ,
             =19 v5 +5 ,
             =26 v6 +3 ,
             =31 v7
say "Fields - Absolute"
say "Parse Var str =2 v1 +2 =5 v2 +4 ... ... ... "
say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
say ""

exit

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
novalue:
say  "** "copies("- ",35)
say  "** Novalue trapped, at line("sigl") var('"condition("D")"') "
exit


the result

Code: Select all

Word Parsing (1)
Parse Var str v1 v2 v3 . v4 v5 . v6 v7 v8
V1 >We<
V2 >have<
V3 >met<
V4 >enemy,<
V5 >and<
V6 >is<
V7 >us.<
V8 ><

Word Parsing (2)
Parse Var str v1 v2 v3 . v4 v5 v6
V1 >We<
V2 >have<
V3 >met<
V4 >enemy,<
V5 >and<
V6 >he is us. <
V7 ><
V8 ><

Word Parsing (3)
Parse Var str v1
V1 > We have met the enemy, and he is us. <
V2 ><
V3 ><
V4 ><
V5 ><
V6 ><
V7 ><
V8 ><

Absolute Position Patterns (1)
Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6
V1 > We have <
V2 >met<
V3 >the<
V4 ><
V5 > enemy, <
V6 >and he is us. <
V7 ><
V8 ><

Relative Position Patterns (1)
Parse Var str 1 v1 +9 v2 v3 v4 +7 v5 +8 v6
V1 > We have <
V2 >met<
V3 >the<
V4 ><
V5 > enemy, <
V6 >and he is us. <
V7 ><
V8 ><

Absolute Position Patterns (2)
Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6 1 v7 v8
V1 > We have <
V2 >met<
V3 >the<
V4 ><
V5 > enemy, <
V6 >and he is us. <
V7 >We<
V8 >have met the enemy, and he is us. <

Absolute Position Patterns (3)
Parse Var str 1 v1 =25 v2 =15 . v3 =19 v4 =5 v5
V1 > We have met the enemy, <
V2 >and he is us. <
V3 >e<
V4 >nemy, and he is us. <
V5 >have met the enemy, and he is us. <
V6 ><
V7 ><
V8 ><

Relative Position Patterns (3)
Parse Var str 1 v1 +24 v2 -10 . v3 +4 v4 -14 v5
V1 > We have met the enemy, <
V2 >and he is us. <
V3 >e<
V4 >nemy, and he is us. <
V5 >have met the enemy, and he is us. <
V6 ><
V7 ><
V8 ><

Fields - Absolute
Parse Var str =2 v1 +2 =5 v2 +4 ... ... ...
V1 >We<
V2 >have<
V3 >et <
V4 >he <
V5 >nemy,<
V6 >nd <
V7 > is us. <
V8 ><


the test was run using open object rexx
but that should be irrelevant

I do not have TSO handy right now ( I am rebuilding my system )
can a good soul double check - if I typed correctly the parse instructions ;)


cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)


Topic author
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 822
Joined: Wed Sep 11, 2013 3:57 pm
Been thanked: 69 times

Re: rexx parse for dummies

Postby enrico-sorichetti » Wed Oct 12, 2016 5:02 pm

a shorter version ( with a loop using interpret )

Code: Select all

#! /usr/bin/env rexx

Trace "O"
signal on novalue name novalue

str         = " We have met the enemy, and he is us. "

parse.1     = "Parse Var str v1 v2 v3 v4 v5 v6 v7 v8"
parse.2     = "Parse Var str v1 v2 v3 . v4 v5 . v6 v7 v8"
parse.3     = "Parse Var str v1 v2 v3 . v4 v5 v6"
parse.4     = "Parse Var str v1"
parse.5     = "Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6"
parse.6     = "Parse Var str 1 v1 +9 v2 v3 v4 +7 v5 +8 v6"
parse.7     = "Parse Var str 1 v1 =10 v2 v3 v4 17 v5 =25 v6 1 v7 v8"
parse.8     = "Parse Var str 1 v1 =25 v2 =15 . v3 =19 v4 =5 v5"
parse.9     = "Parse Var str 1 v1 +24 v2 -10 . v3 +4 v4 -14 v5"
parse.10    = "Parse Var str =2 v1 +2  =5 v2 +4 =11 v3 +3 =15 v4 +3 =19 v5 +5 =26 v6 +3 =31 v7"
parse.11    = ""
parse.12    = ""

descr.1     = "parse everything ( not in the slides ) "
descr.2     = "Word Parsing (1)"
descr.3     = "Word Parsing (2)"
descr.4     = "Word Parsing (3)"
descr.5     = "Absolute Position Patterns (1)"
descr.6     = "Relative Position Patterns (1)"
descr.7     = "Absolute Position Patterns (2)"
descr.8     = "Absolute Position Patterns (3)"
descr.9     = "Relative Position Patterns (3)"
descr.10    = "Fields - Absolute"
descr.11    = ""
descr.12    = ""


parse.0     = 10


do  p = 1 to parse.0
    v1 = ""; v2 = ""; v3 = ""; v4 = ""; v5 = ""; v6 = ""; v7 = ""; v8 = "";
    interpret parse.p

    say ""
    say descr.p
    say parse.p
    say "V1 >"v1"<"; say "V2 >"v2"<"; say "V3 >"v3"<"; say "V4 >"v4"<";
    say "V5 >"v5"<"; say "V6 >"v6"<"; say "V7 >"v7"<"; say "V8 >"v8"<";
    say ""
end

say ""

exit

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
novalue:
say  "** "copies("- ",35)
say  "** Novalue trapped, at line("sigl") var('"condition("D")"') "
exit



again ... can a good soul double check - if I typed correctly the parse instructions ;)


cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)


Nikhil Nigam
New Member
Posts: 4
Joined: Sat May 21, 2016 7:24 am

Re: rexx parse for dummies

Postby Nikhil Nigam » Sun Oct 23, 2016 2:05 pm

Thanks for the examples. We can practice this code on our home PC also right,no need to mainframe?




Topic author
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 822
Joined: Wed Sep 11, 2013 3:57 pm
Been thanked: 69 times

Re: rexx parse for dummies

Postby enrico-sorichetti » Sun Oct 23, 2016 2:43 pm

yes, You can exercise REXX on Your PC,
just install ooRexx (open object rexx) available here

https://sourceforge.net/projects/oorexx ... exx/4.2.0/


cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)


Return to “REXX”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests