tparker@bierstadt.scd.ucar.edu (Tom Parker) (11/28/90)
Here's a question regarding PARSEing in REXX on VM/CMS: In parsing, I know you can use a string pattern in a variable, by putting it in parentheses. For example: slash = '/' parse value 'dog/cat' with word1 (slash) word2 But I can't find how to use a NUMERIC pattern in a variable. For example, I might want to break a string at a specific column determined by the program. Simplistic example: column = 4 parse value 'dog/cat' with word1 (column) word2 will use '4' as a string pattern, rather than as a number pattern. So, my question is: is there a way to use a numeric pattern in a variable when parsing? Thanks for any help. Tom Parker National Center for Atmospheric Research tparker@ncar.ucar.edu
MADIF@ROHVM1.BITNET (Jim Foster) (11/28/90)
In article <9304@ncar.ucar.edu>, tparker@bierstadt.scd.ucar.edu (Tom Parker) says: > >Here's a question regarding PARSEing in REXX on VM/CMS: > >In parsing, I know you can use a string pattern in a variable, by putting >it in parentheses. For example: > > slash = '/' > parse value 'dog/cat' with word1 (slash) word2 > >But I can't find how to use a NUMERIC pattern in a variable. For >example, I might want to break a string at a specific column determined >by the program. Simplistic example: > > column = 4 > parse value 'dog/cat' with word1 (column) word2 > >will use '4' as a string pattern, rather than as a number pattern. > > >So, my question is: is there a way to use a numeric pattern in a variable >when parsing? > Put an "=" sign in front of the parentheses. I think you need REXX v4 to do this. column = 4 parse value 'dog/cat' with word1 =(column) word2 For more information, see Cowlishaw, second edition, page 119. -- Jim Foster - MADIF@ROHVM1.BITNET Rohm and Haas Company Systems Programmer Independence Mall West (215) 592-2446, 592-3377 (FAX) Philadelphia, PA 19105
brooking@mcnc.org (Jim Brooking) (11/29/90)
In article <9304@ncar.ucar.edu>, tparker@bierstadt.scd.ucar.edu (Tom Parker) writes: > > But I can't find how to use a NUMERIC pattern in a variable. For > example, I might want to break a string at a specific column determined > by the program. Simplistic example: > > column = 4 > parse value 'dog/cat' with word1 (column) word2 > > will use '4' as a string pattern, rather than as a number pattern. > This seems to do the job: /* Parse something with a variable column */ col = 4 xyz = 12345678 z = "parse var xyz var1" col "varn" interpret z say var1 varn At least it works on uniREXX; I don't have a CMS account at the moment. -- >8-} >:-) %\( 8^) :+/ |'[ ;-) :-O B^\ :-) Jim Brooking........North Carolina Supercomputing Center.......(919)248-1145
bzr10@ccc.amdahl.com (Bruce Richardson) (11/29/90)
How about using INTERPRET? As in... number = 4 interpret "parse value 'dog/cat' with word1 "number" word2" By the way (BTW?): the =(number) construct did not work on my TSO/E system with REXX370 3.45! Regards, Bruce As usual, the opinions express in this document are my own, and do not reflect upon my employer.
OPRJ36@TREARN.BITNET (Bahri Bora BALI AG) (11/29/90)
Hello! I don't fi we are talking about Rexx370 parser. But The following code does what you would like to do (using numeric pattern in parsing)... Here is it: /* */ Trace off begcol = 17 endcol = 21 rxcmd = "Parse value DIAG(8,'CP QUERY CPUID') with" begcol "cpuid" endcol Interpret rxcmd Say "CPU model:" cpuid Exit
king@motcid.UUCP (Steven King) (11/30/90)
In article <9304@ncar.ucar.edu> tparker@bierstadt.scd.ucar.edu (Tom Parker) writes: >In parsing, I know you can use a string pattern in a variable, by putting >it in parentheses. For example: > > slash = '/' > parse value 'dog/cat' with word1 (slash) word2 > >But I can't find how to use a NUMERIC pattern in a variable. For >example, I might want to break a string at a specific column determined >by the program. Simplistic example: > > column = 4 > parse value 'dog/cat' with word1 (column) word2 > >will use '4' as a string pattern, rather than as a number pattern. You're trying to parse everything *BEFORE* the fourth column into the variable "word1" and everything *AFTER* the fourth column into "word2". Try it this way: parse value 'dog/cat' with 1 word1 4 . 5 word2 This template tells REXX to start start parsing the first variable in column 1, the second variable (".", the dummy variable) in column 4, and the third variable in column 5. You'll end up with "word1" set to "dog" and "word2" set to "cat". The slash will be assigned to the dummy variable and discarded. By the way, to parse on a single character (or a string for that matter) you don't need to fool around with assigning it to a variable and putting it in parentheses if you don't want to. Simply, parse value 'dog/cat' with word1 "/" word2 will work just fine to assign "dog" to "word1" and "cat" to "word2". -- ---------------------------------------------------+--------------------------- Never let anyone know you're good at something | Steven King you dislike. You'll find yourself doing it | Motorola Cellular forever. | ...uunet!motcid!king
QQ11@LIVERPOOL.AC.UK (Alan Thew) (12/01/90)
In article <9304@ncar.ucar.edu>, tparker@bierstadt.scd.ucar.edu (Tom Parker) says: > >Here's a question regarding PARSEing in REXX on VM/CMS: > >In parsing, I know you can use a string pattern in a variable, by putting >it in parentheses. For example: > > slash = '/' > parse value 'dog/cat' with word1 (slash) word2 > >But I can't find how to use a NUMERIC pattern in a variable. For >example, I might want to break a string at a specific column determined >by the program. Simplistic example: > > column = 4 > parse value 'dog/cat' with word1 (column) word2 > >will use '4' as a string pattern, rather than as a number pattern. > > >So, my question is: is there a way to use a numeric pattern in a variable >when parsing? > Try parse var 'dog/cat' word1 4 5 word2 This will assign "dog" to word1 and "cat" to word2 and omit the "/" REXX also allows relative patterns e.g. the above could be parse var 'dog/cat' word1 4 +1 word2 Alan Thew : University of Liverpool Computer Laboratory Bitnet/Earn: QQ11@LIVERPOOL.AC.UK or QQ11%UK.AC.LIVERPOOL @ UKACRL UUCP : ....!mcsun!ukc!liv!qq11 Voice : +44 51 794 3735 FAX : +44 51 794 3759 Internet : QQ11@LIVERPOOL.AC.UK or QQ11%LIVERPOOL.AC.UK @ NSFNET-RELAY.AC.UK