Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bob Eager Newsgroups: alt.folklore.computers,comp.lang.rexx Subject: Re: The joy of FORTRAN Date: 29 Sep 2024 10:18:47 GMT Lines: 71 Message-ID: References: <5mqdnZuGq4lgwm_7nZ2dnZfqnPSdnZ2d@earthlink.com> <36KdnVlGJu9VLW77nZ2dnZfqn_qdnZ2d@earthlink.com> <20240927113205.b0ccfb4910eb89f27f138cbb@127.0.0.1> <20240928093323.cfbd5563af05e97315be1989@127.0.0.1> <20240929091910.ef0649ce9c20122b9bdcadae@127.0.0.1> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net 1t+AjDG66vDlCrEKaDjmmgBPl3B9yLqFRuR9MkL7aKGp/c4ZF1 Cancel-Lock: sha1:6JXvjcXXyEI7S65M45f1ugPhsRs= sha256:lVw12Fyt29xaDjv7VODppHTtGeRtkX6GnsppnC6Eq7g= User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a git.gnome.org/pan2) Xref: csiph.com alt.folklore.computers:227208 comp.lang.rexx:3843 On Sun, 29 Sep 2024 11:23:18 +0200, R Daneel Olivaw wrote: > Kerr-Mudd, John wrote: >> On 28 Sep 2024 09:41:59 GMT Bob Eager wrote: >> >>> On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote: >>> >>>> I was too lazy to dig into my rusty brain to code the equivalent in >>>> Rexx, >>>> I was hoping someone here would do it! >>>> >>>>>>>> for item in "the,quick,brown,fox".split(",") : >>>>>>>> print(item) >>>>>>>> #end for >>>> >>>> OK,OK. Cribbed & hacked from a stackoverflow answer: >>>> https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line- >>> separator >>>> >>>> >>>> myline="the,quick,brown,fox" >>>> >>>> do i = 1 by 1 while myline <> '' >>>> parse var myline w.i ',' myline >>>> end w.0 = i-1 >>>> >>>> do i = 1 to w.0 >>>> say w.i >>>> end >>>> >>>> >>>> Hmm, must be a shorter way without the bother of setting up the stem >>>> array. >>> >>> If you use space as a delimiter, which I would argue is more natural: >>> >>> ------------------------------------------ >>> myline="the quick brown fox" >>> >>> do i = 1 to words(myline) >>> say word(myline, i) >>> end ------------------------------------------ >>> >>> >> Thanks; It's been yea^w decades since I used Rexx. And even then not >> extensively. But Rexx has "Parse" which few(no?) other languages have. >> >> > What does "parse" do? > I just had a look at some REXX documentation but it was not particularly > helpful, it looked to me to be something which a couple of FORTRAN 77 > function calls would have handled perfectly adequately. It essentially splits a string into substrings, using specified delimiters. The source string may be from a variety of places (variable, argument array, input line, stack) and there are some weird special cases such as getting the version number. Essentially, you specify a template and it splits the string in accordance with that. For example: parse var s1 "," s2 "-" s3 -- Using UNIX since v6 (1975)... Use the BIG mirror service in the UK: http://www.mirrorservice.org