Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!olivea!oliveb!amiga!jimm From: jimm@amiga.UUCP (Jim Mackraz) Newsgroups: comp.lang.rexx Subject: Re: Iterating on Stems Message-ID: <6423@amiga.UUCP> Date: 11 Mar 91 20:27:18 GMT References: <1991Mar9.215906.4976@ssd.kodak.com> Organization: I and I Computing, Palo Alto, CA Lines: 44 (Jeff Van Epps) writes: )Hi gang. I just got ARexx, and I've translated some Perl scripts to Arexx. )The Perl scripts used associative arrays, for which the ARexx equivalent )seems to be "stems" or "compound symbols". Putting data in worked fine, )but getting them out was more complicated than necessary. ) )PERL: while (($key,$value) = each(assocary)) { /* stuff */ } ) )ARexx: ??? ) )The question is, once you've stored the data, how do you get the system )to iterate over the "array", telling you the keys? ) )I solved it by storing the keys at the same time as the data, in a more )normal array (keys.1 keys.2 keys.3 etc.), with a count of how many keys )have been processed so far. But this strikes me as a kludgy workaround for )a missing language feature. Does the language feature exist and I just )missed it?? Isn't that a bitch? That's bugged me often. Since external host programs can access and modify a running script/exec's symbol table (using the RVI methods), it struck me that this "missing piece" would have been very useful. Note that even the compiled host program using RVI cannot iterate the stems.. The method you describe, using numbers as stem fields, is common. People often place the count in keys.0. You could also be more "symbolic" with fields foo.Name, foo.Addrress, foo.Phone, foo.ExtraPhone, foo.Fax, and so on, and stash the field name list in foo.Fields = "Name Address Phone ExtraPhone" Then you could say something like: do i = 1 to words( foo.Fields ) field = word( foo.Fields, i ) say field||':' foo.Fields end jimm -- --- opinions expressed herein are my own. --- "... Because they can." - profound punchline to joke about dogs