🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.rexx
26 messages
26 total messages Started by pyutzy Wed, 20 Mar 1996 03:29
REXX Arrays? Possible
#4247
Author: pyutzy
Date: Wed, 20 Mar 1996 03:29
2 lines
540 bytes
I am attempting to use VX-REXX and didn't find anything concerning 
arrays in the documentation, did I miss something?
Re: REXX Arrays? Possible
#4252
Author: CBARTLE1
Date: Wed, 20 Mar 1996 09:26
15 lines
830 bytes
In article <4inu2e$sv0@mycogen.terminus.com>, pyutzy@seldon.terminus.com says:
>
>I am attempting to use VX-REXX and didn't find anything concerning
>arrays in the documentation, did I miss something?
 
You should look at Compound Variables which are a bit like arrays and a
bit different. eg:-
 
    /* */
    i=2
    j=3
    something.i.j = 'Hit it'
    say something.2.3
 
Regards, Chris.
Re: REXX Arrays? Possible
#4255
Author: dwright
Date: Wed, 20 Mar 1996 17:31
6 lines
735 bytes
In <4inu2e$sv0@mycogen.terminus.com>, pyutzy@seldon.terminus.com writes:
>I am attempting to use VX-REXX and didn't find anything concerning 
>arrays in the documentation, did I miss something?

Yes...read the documentation under OS/2 for REXX (Not VX-REXX).  Search for
"STEM" and you should find what you are looking for.  
Re: REXX Arrays? Possible
#4296
Author: Stone
Date: Sat, 23 Mar 1996 22:40
36 lines
1437 bytes
In message <96080.102619CBARTLE1@estec.estec.esa.nl> - 
<CBARTLE1@estec.estec.esa.nl> writes:
:>You should look at Compound Variables which are a bit like arrays and a
:>bit different. eg:-
:> 
:>    /* */
:>    i=2
:>    j=3
:>    something.i.j = 'Hit it'
:>    say something.2.3
:> 
:>Regards, Chris.
Let me get this straight:

Coudl I also modify your code to do this?
	
	i=2
	j=3
	something.i-1.j-1 = 'Hit it'
	say something.1.2

This would work?  

I have the demo version of VX-REXX and not all of the features are enabled, 
so this may sound like a lame question?  I'm trying to decide the best way to 
break into OS/2 programming.  I'm tending towards C, which I've used in the 
past (non-visual, though).  

Does REXX muscle up to build some pretty powerful apps?	


David W. Yutzy
Proud to be Warp'd

BlueMoon: http://www.terminus.com/~dyutzy/BlueMoon.html
NetClock: http://www.terminus.com/~dyutzy/netclock.html
Re: REXX Arrays? Possible
#4297
Author: Stone
Date: Sat, 23 Mar 1996 22:40
36 lines
1437 bytes
In message <96080.102619CBARTLE1@estec.estec.esa.nl> - 
<CBARTLE1@estec.estec.esa.nl> writes:
:>You should look at Compound Variables which are a bit like arrays and a
:>bit different. eg:-
:> 
:>    /* */
:>    i=2
:>    j=3
:>    something.i.j = 'Hit it'
:>    say something.2.3
:> 
:>Regards, Chris.
Let me get this straight:

Coudl I also modify your code to do this?
	
	i=2
	j=3
	something.i-1.j-1 = 'Hit it'
	say something.1.2

This would work?  

I have the demo version of VX-REXX and not all of the features are enabled, 
so this may sound like a lame question?  I'm trying to decide the best way to 
break into OS/2 programming.  I'm tending towards C, which I've used in the 
past (non-visual, though).  

Does REXX muscle up to build some pretty powerful apps?	


David W. Yutzy
Proud to be Warp'd

BlueMoon: http://www.terminus.com/~dyutzy/BlueMoon.html
NetClock: http://www.terminus.com/~dyutzy/netclock.html
Re: REXX Arrays? Possible
#4298
Author: Stone
Date: Sat, 23 Mar 1996 22:41
36 lines
1437 bytes
In message <96080.102619CBARTLE1@estec.estec.esa.nl> - 
<CBARTLE1@estec.estec.esa.nl> writes:
:>You should look at Compound Variables which are a bit like arrays and a
:>bit different. eg:-
:> 
:>    /* */
:>    i=2
:>    j=3
:>    something.i.j = 'Hit it'
:>    say something.2.3
:> 
:>Regards, Chris.
Let me get this straight:

Coudl I also modify your code to do this?
	
	i=2
	j=3
	something.i-1.j-1 = 'Hit it'
	say something.1.2

This would work?  

I have the demo version of VX-REXX and not all of the features are enabled, 
so this may sound like a lame question?  I'm trying to decide the best way to 
break into OS/2 programming.  I'm tending towards C, which I've used in the 
past (non-visual, though).  

Does REXX muscle up to build some pretty powerful apps?	


David W. Yutzy
Proud to be Warp'd

BlueMoon: http://www.terminus.com/~dyutzy/BlueMoon.html
NetClock: http://www.terminus.com/~dyutzy/netclock.html
Re: REXX Arrays? Possible
#4299
Author: Stone
Date: Sat, 23 Mar 1996 22:41
36 lines
1437 bytes
In message <96080.102619CBARTLE1@estec.estec.esa.nl> - 
<CBARTLE1@estec.estec.esa.nl> writes:
:>You should look at Compound Variables which are a bit like arrays and a
:>bit different. eg:-
:> 
:>    /* */
:>    i=2
:>    j=3
:>    something.i.j = 'Hit it'
:>    say something.2.3
:> 
:>Regards, Chris.
Let me get this straight:

Coudl I also modify your code to do this?
	
	i=2
	j=3
	something.i-1.j-1 = 'Hit it'
	say something.1.2

This would work?  

I have the demo version of VX-REXX and not all of the features are enabled, 
so this may sound like a lame question?  I'm trying to decide the best way to 
break into OS/2 programming.  I'm tending towards C, which I've used in the 
past (non-visual, though).  

Does REXX muscle up to build some pretty powerful apps?	


David W. Yutzy
Proud to be Warp'd

BlueMoon: http://www.terminus.com/~dyutzy/BlueMoon.html
NetClock: http://www.terminus.com/~dyutzy/netclock.html
Re: REXX Arrays? Possible
#4300
Author: tnagy
Date: Sun, 24 Mar 1996 15:01
28 lines
1322 bytes
In <4j1ulf$boh@mycogen.terminus.com>, dyutzy@terminus.com (Stone) writes:
>In message <96080.102619CBARTLE1@estec.estec.esa.nl> - 
>Coudl I also modify your code to do this?
>	
>	i=2
>	j=3
>	something.i-1.j-1 = 'Hit it'

Nope, it would mean something.i MINUS 1.j MINUS 1
The 1.j part would result in a sytax error, since a variable name cannot
start with a digit.

>	say something.1.2

This is OK and would give you SOMETHING.1.2 as a result, unless you have
initialized something. like this: something. = 'HELLO', in which case the above
line would give the result HELLO.

>I have the demo version of VX-REXX and not all of the features are enabled, 

All the features are enabled in the VX-REXX demo, except you cannot save
or make an executable.

>Does REXX muscle up to build some pretty powerful apps?	

You will have to define what 'pretty powerful apps' means.

Tom
Re: REXX Arrays? Possible
#4310
Author: Cem Turgay
Date: Mon, 25 Mar 1996 10:30
19 lines
929 bytes
> >Coudl I also modify your code to do this?
> >
> >       i=2
> >       j=3
> >       something.i-1.j-1 = 'Hit it'
>

Today's magic word is...

"interpret"

Try this,

interpret something.(i-1).(j-1) "=" 'Hit it'

(But do not forget to put = inside quotes)


Cem Turgay
Re: REXX Arrays? Possible
#4313
Author: bob
Date: Mon, 25 Mar 1996 16:38
11 lines
874 bytes
In <315675D7.7DE14518@eurocontrol.de>, Cem Turgay <tur@EUROCONTROL.DE> writes:
>> >Coudl I also modify your code to do this?
>> >
>> >       i=2
>> >       j=3
>> >       something.i-1.j-1 = 'Hit it'

You can also do this w/o Interpret by using temp variables:

i = 2
j = 3
Re: REXX Arrays? Possible
#4316
Author: CFORDE
Date: Mon, 25 Mar 1996 22:37
32 lines
1252 bytes
>In <315675D7.7DE14518@eurocontrol.de>, Cem Turgay <tur@EUROCONTROL.DE> writes:
>>> >Coudl I also modify your code to do this?
>>> >
>>> >       i=2
>>> >       j=3
>>> >       something.i-1.j-1 = 'Hit it'
>
>You can also do this w/o Interpret by using temp variables:
>
>i = 2
>j = 3
 
Better yet, use value().  Eg.
 
/**/
i = 2
j = 3
oldthing = value('something.'i-1'.'j-1,'Hit it')
say something.1.2
 
says:
 
Hit it
 
As a bonus "oldthing" contains the value of the variable before
the assignment was done.  Could be useful.
 
Have fun,                          phonenet: 604-389-3234
Carl Forde                         bitnet  : CFORDE at BCSC02
VM Systems Software Group          internet: cforde@bcsc02.gov.bc.ca
British Columbia Systems Corp.     webnet  : bcsc02.gov.bc.ca/~cforde/
There's no food in my dad's kitchen; all he has are ingredients
Re: REXX Arrays? Possible
#4347
Author: RGREEN
Date: Wed, 27 Mar 1996 03:12
8 lines
865 bytes
In <4inu2e$sv0@mycogen.terminus.com>, pyutzy@seldon.terminus.com writes:
>I am attempting to use VX-REXX and didn't find anything concerning 
>arrays in the documentation, did I miss something?
>
No you didn't. Native REXX doen't support arrays. Some may argue that 
extension variables give array like characteristics but, except for some
simple indexing, of course they don't. 
 
Re: REXX Arrays? Possible
#4358
Author: Ian Collier
Date: Wed, 27 Mar 1996 12:13
35 lines
1968 bytes
In article <4j3o4s$1c4u@news-s01.ny.us.ibm.net>, tnagy@ibm.net wrote:
>>	something.i-1.j-1 = 'Hit it'

>Nope, it would mean something.i MINUS 1.j MINUS 1
>The 1.j part would result in a sytax error, since a variable name cannot
>start with a digit.

Well, strictly speaking, the syntax error would be because of the attempt
to use 1.J (which is not a number) in a subtraction.  You are allowed to
write it: the instruction "say 1.j" will say 1.J because 1.j is what is
known as a constant symbol.  The fact that it is constant means, however,
that you cannot write something like "1.j = 3".

For the original questioner, if you want the value of something.(i-1).(j-1)
then you will have to write

  tmpi = i-1
  tmpj = j-1
  say something.tmpi.tmpj

or

  say value("something." || i-1 || "." || j-1)

both of which have the effect of calculating the array subsripts before
putting them on to the end of the variable name.  It's a minor inconvenience
that we all live with...  except those people who have special versions
of Rexx that can interpret the above things with the brackets (I seem to
remember that Object Rexx does this).

Ian Collier - imc@comlab.ox.ac.uk - WWW Home Page (including REXX section):
http://www.comlab.ox.ac.uk/oucl/users/ian.collier/index.html

New to this group?  Answers to frequently-asked questions can be had from
http://rexx.hursley.ibm.com/rexx/ .
Re: REXX Arrays? Possible
#4388
Author: Anthony de Vries
Date: Thu, 28 Mar 1996 08:20
26 lines
1719 bytes
RGREEN@CMHC.e-mail.com@198.53.144.2 wrote:
> 
> In <4inu2e$sv0@mycogen.terminus.com>, pyutzy@seldon.terminus.com writes:
> >I am attempting to use VX-REXX and didn't find anything concerning
> >arrays in the documentation, did I miss something?
> >
> No you didn't. Native REXX doen't support arrays. Some may argue that
> extension variables give array like characteristics but, except for some
> simple indexing, of course they don't.
 
Hmm, as a former Pascal programmer, I'm very curious to find out
why REXX arrays aren't and Pascal arrays are!

Is it because REXX arrays aren't packed or so? (are they?)
Harldy a good reason in a language where pure speed is less important.

What I DO like is that I can do MUCH more with the REXX compound 
variable than I could in Pascal. I can let the array grow in length
as I need, and don't have to make ugly linked lists for it. Also 
indexing the array with strings gives very nice solutions to problems.'

But I'm always eager to learn, so please explain why REXX arrays
aren't arrays!


Anthony.
Re: REXX Arrays? Possible
#4405
Author: Ian Collier
Date: Thu, 28 Mar 1996 13:46
20 lines
1386 bytes
In article <315675D7.7DE14518@eurocontrol.de>, Cem Turgay <tur@EUROCONTROL.DE> wrote:
>Try this,

>interpret something.(i-1).(j-1) "=" 'Hit it'

>(But do not forget to put = inside quotes)

Do not also forget to put 'something.' inside quotes, just in case it has a
value, and if you intend to use those parentheses then make sure you use a
concatenation operator (||) to join the pieces together, because what you
have there is (I think) two function calls.  In fact the only things that
should not be in quotes are the i-1 and j-1.

interpret "something." || i-1 || "." || j-1 "= 'Hit it'"

Ian Collier - imc@comlab.ox.ac.uk - WWW Home Page (including REXX section):
http://www.comlab.ox.ac.uk/oucl/users/ian.collier/index.html

New to this group?  Answers to frequently-asked questions can be had from
http://rexx.hursley.ibm.com/rexx/ .
Re: REXX Arrays? Possible
#4396
Author: Dave Boll
Date: Thu, 28 Mar 1996 14:50
11 lines
1090 bytes
> No you didn't. Native REXX doen't support arrays. Some may argue that
> extension variables give array like characteristics but, except for some
> simple indexing, of course they don't.

I think that REXX compound variables ("stems", which implement 
sparse arrays) do constitute an implementation of arrays.  REXX 
certainly does not implement structures, but I think it does 
implement arrays.  I may be missing something about arrays that 
you can't do with compound variables.  If so, please clarify.

Thanks.
Re: REXX Arrays? Possible
#4482
Author: RGREEN Ron Green
Date: Tue, 02 Apr 1996 04:37
24 lines
1755 bytes
In <315AA71F.A24@elvis.srl.ford.com>, Dave Boll <dboll@elvis.srl.ford.com> writes:
>> No you didn't. Native REXX doen't support arrays. Some may argue that
>> extension variables give array like characteristics but, except for some
>> simple indexing, of course they don't.
>
>I think that REXX compound variables ("stems", which implement 
>sparse arrays) do constitute an implementation of arrays.  REXX 
>certainly does not implement structures, but I think it does 
>implement arrays.  I may be missing something about arrays that 
>you can't do with compound variables.  If so, please clarify.
>
>Thanks.

I don't want to get into a "you say potEHto, I say potAHto" discussion 
but I view arrays in the traditional HL programming sense: a
single or multidimential collection of like data elements (usually) 
occupying contiguous storage which can be operated upon either
individually, in part, or as a whole. E.g. given the array A(2,2) 
where A(1,1)=1, A(1,2)=2, A(2,1)=3, A(2,2)=4; A=A*2 yields
A(1,1)=2, A(1,2)=4, A(2,1)=6, A(2,2)=8. The foregoing cannot be 
done in REXX. 
Yeah.Yeah. 
do i=1 to 2;do j=1 to 2; a.i.j=a.i.j*2;end;end
But this isn't REALLY array arithmetic.   
Re: REXX Arrays? Possible
#4508
Author: Cem Turgay
Date: Wed, 03 Apr 1996 07:29
23 lines
1466 bytes
Representation methode doesn't show that something is array or not.
You could even use A[1,1] or A*1*1 or (A#1#1) in some other
languages or future languages.

If  "a.i.j=a.i.j * 2" gives the same EFFECT like
"a(i,j)=a(i,j) * 2" then we can say they are same in over
ground.

If you look from under ground, they are not same.
Conventional languages mostly keeps arrays in continuous
byte blocks which could be manipulated by a VECTOR processors
(or MATRIX proc) Rexx does not keep the array elements
in a continuous memory segments even does not keep as binary,
so they are NOT real arrays.

But purpose of Rexx variables are different.
They are wonder of Rexx flexibility...

Let's think:
TEL_NR.JOHN.DOE = xxxxx
Which real array could give us such wonderfull usage ???

Cem Turgay
Re: REXX Arrays? Possible
#4516
Author: Clive Humble
Date: Wed, 03 Apr 1996 17:15
58 lines
2509 bytes
This has been an interesting discussion! and it leads me to ask for some
info if that's OK!


I've got a stem (as I prefer to call them) which holds the index returned
from (not that is matters) a 'SetItem' in VisPro.  It is essentially a
unique 'index' reference.

I grab is thus

indx = VpSetItem Whatever whatever (say adding icons to a container)

The point is that indx would then hold a large unique value, say, 8765321.

I then construct a stem..

data.indx.1 = 'd:\foo\etc\filename.ext'   /* for the sake of this example */
data.indx.2 = 'something else for this example'.



Now, what I find incredibly useful is that I can get to my filename example
by simply refering to


data.8765321.1


Given the large number, 'ck knows what it would take to finally get to
data.87654321.1 to grab the value with conventional arrays.  With rexx's
ability to get straight to the 'element' of the 'array' in one
move...well..I am impressed!

Now, the questions...

(i) Is there a limit as to the 'value' in, say, my example..?  ie: would
    data.99999999.1 suddenly break !?

(ii) What is the largest amount of data I can chuck into a rtexx variable ?
     (I do a historical check on incoming data which I concatenate into
     a massive string variable...  a positive or negative POS(needle, haystack)
     informs me whether the pertinent data is already accounted for.  I am
     just wondering whether there is a final limit as to what can be
     stored in a single variable before I unleash it!)


Rexx stems ain't arrays.  But arrays ain't stems!

Cheers!


Clive
,c.
-- 
------------------------------------------------------------------------
Clive Humble of Artists in Glass, England, Atlantic Ocean (+near+ Europe)
   Desk: chumble@glassnet.com      Home: chumble@agile.glassnet.com
------------------------------------------------------------------------
Re: REXX Arrays? Possible
#4519
Author: bob
Date: Wed, 03 Apr 1996 17:57
27 lines
2026 bytes
In <316228F4.FF6D5DF@eurocontrol.de>, Cem Turgay <tur@EUROCONTROL.DE> writes:
>Conventional languages mostly keeps arrays in continuous
>byte blocks which could be manipulated by a VECTOR processors
>(or MATRIX proc) Rexx does not keep the array elements
>in a continuous memory segments even does not keep as binary,
>so they are NOT real arrays.

Could you cite for me where Arrays are defined as having to be in contiguous
storage? Or that the values in an array must be kept as binary? You're making
assumptions which are not valid, and trying to force them on others.

By your definition, an array of strings is not an array (Although, if strings aren't 
stored in binary, then what are they stored in? A character is a BINARY 
representation, is it not?) PL/I multi-dimentional arrays were stored oriented
90 degrees off from the way other languages did it. Does that mean that they
weren't arrays?

REXX implements arrays in such a way as to allow sparse arrays (ie: with holes
in the sequence), which conserves storage. REXX is a text-oriented language,
and as such, stores numbers as their text representation. Does this disqualify
REXX as a computer language entirely? You'd also have to drop SNOBOL from 
the list, since it does the same thing.

I'd really like you to cite something in print which says arrays must be contiguous
and contain binary values. Otherwise, you're just blowing smoke.

Bob Nix
Re: REXX Arrays? Possible
#4538
Author: Cem Turgay
Date: Thu, 04 Apr 1996 09:50
87 lines
4462 bytes
Bob,

My definition was not incorrect.
I'll explain you how Rexx arrays and other conventional arrays work.
(Real array, I prefer to say conventional array instead of real,
anf for the Rexx, I call them virtual array.)

Conventional languages NEVER spread their array elements on the
memory out of order.
Of course, It's not possible for indexed arrays,
you should put elements in sequence, in order, otherwise
you cannot access them by index numbers !

An example: your conventional array has 100 elements each 4 byte long.

In any point, you (or the language) only have it's starting address.
If you want to reach 50.th element, language/compiler itself
compute the element address as start_adres + (50 x 4 )
This is the mechanism behind the conventional array logic.
If one of them is 5 byte long OR one of them is out of
sequence, then you'd better hit your head to the wall
instead of try to access..

In parallel or vectorized computers, lets say 100 processors,
each processor can manipulate each elements of your array
at the same time (or same clock tick). This is also very important
for the array definition and logic... Most compilers take care of it.
My binary form idea was completely related to such computers,
not in general.
My sayings was simplified the subject in wrong direction.
Correct one could be,
you must able to keep arrays in binary, I mean, known arithmetic
representation types, to manipulate them in vectorized
computers. Otherwise no benefit from vector processors, super
computers or multi-processor machines... They are mostly builded
on the base of the conventional ARRAY LOGIC. Not for Rexx arrays !
This is the big difference.

The process way of the matrix map is not realy important, the PL/1 in
your example, it still keeps the elements in order, in a contigious
memory segments. It can access every element with a simple
math calculation (coordinate * size of cell) allways...
You are able to reverse the coordinates of the matrix map in any
case...

If you have a different sized elements or inordered elements,
then you need another mechanism to handle arrays or matrixes.
It will be different than conventional array logic.
Like Rexx...

Rexx stores stems (or arrays in our mind) in random order,
even, every element of stem could be different length,
and different type of data... And most importantly not
the same kind of indexes !
Rexx searches it's elements by name (not accessed by it's index)

Rexx does not implement arrays such to allow sparse arrays
(unknown for me) (i.e with holes in the sequence)
No way, because there is no sequence B-)

In truth, Rexx does not have even indexed elements nor arrays.
All you have is virtual arrays, virtual matrixes, virtual indexes...

Everthing is keeping by contiguous variable name in the memory.
When you declare a stem let say, MYARRAY.ONE.TWO.THREE = 10

THERE IS NO ELEMENT in the memory like third of second of first of
myarray. The name "MYARRAY.ONE.TWO.THREE" is complete name of a
variable, an ORDINARY variable ... (myarray.1.2.3 also same)
And the variable name structure holds the pointer of its data.
It makes data length also flexible.

Stems, arrays or matrix LIVE IN OUR MIND !

And Rexx searches the name "MYARRAY.ONE.TWO.THREE" in its linked
variable list. Each element of any array or matrix could be
in somewhere (undefined, undetermined) position in the memory.
You should just need to search for it.

And as I said, I love Rexx's virtual arrays. It's kind of
intelligent way to keep it as flexible as..

I don't need to show you a printed material which says Cem is true...
I myself have written 2 compiler and an interpreter and lots
of tools in assembly to manipulate Rexx variables...

Cem Turgay
Re: REXX Arrays? Possible
#4758
Author: Mark Tucker
Date: Thu, 18 Apr 1996 02:02
8 lines
877 bytes
Excuse my ignorance, I'm very new to using rexx and I'm just getting around to
playing with arrays.  How does Rexx distinguish between an array named
somthing like array_var.1 array_var.2 and the use of another variable to
manipulate the variable such as array_var.loop_counter?  I'm coming from BASIC
(sorry) experience.

Tks,
/\/\ark
Re: REXX Arrays? Possible
#4761
Author: Cem Turgay
Date: Fri, 19 Apr 1996 07:35
16 lines
1332 bytes
Mark Tucker wrote:
>
> Excuse my ignorance, I'm very new to using rexx and I'm just getting around to
> playing with arrays.  How does Rexx distinguish between an array named
> somthing like array_var.1 array_var.2 and the use of another variable to
> manipulate the variable such as array_var.loop_counter?  I'm coming from BASIC
> (sorry) experience.

Same as BASIC does. It substitutes loop_counter with its value.

For i=1 To N                    Do i=1 To N
  array(i) = i*2                  array.i = i*2
Next i                          End


Cem
Re: REXX Arrays? Possible
#4771
Author: bob
Date: Fri, 19 Apr 1996 18:16
36 lines
2227 bytes
In <zKadxsDmfW4V084yn@plainfield.bypass.com>, mtucker@plainfield.bypass.com (Mark Tucker) writes:
>Excuse my ignorance, I'm very new to using rexx and I'm just getting around to
>playing with arrays.  How does Rexx distinguish between an array named
>somthing like array_var.1 array_var.2 and the use of another variable to
>manipulate the variable such as array_var.loop_counter?  I'm coming from BASIC
>(sorry) experience.

The .1 and .2 endings are taken as a literal 1 and 2 and used to construct the 
variable names to search for, just as they were given. the .loop_counter
specifies a variable, and the variable is resolved before looking up the 
array variable. If loop_counter has a value of 2, then this would resolve to 
the same variable name as the .2 ending would.

Note that the indices do not necessarily need to be numeric. You can set
loop_counter = 'ME', and use it, and it will resolved to a name ending in .ME,
which is just as valid an index as .2. This would allow you to do something 
like count the occurances of words in a file easily. 

counts. = 0
allwords = ''
Do forever
  Nextwd = GetNextWd()
  If Nextwd = '' then leave
  counts.Nextwd = counts.Nextwd + 1
  If counts.Nextwd = 1 then Allwords = Allwords Nextwd
end

You now have one occurance of each word used in Allwords, and the counts
of each word's use in counts. If "the" is one of the words used, then 
counts.the contains the number of times the word was used. (In practice, you'd
want to upper case the words before indexing them, so that THE would equal
the would equal The, etc.)

Hope this helps

Bob Nix
Re: REXX Arrays? Possible
#4767
Author: Mark VanTassel
Date: Fri, 19 Apr 1996 21:45
39 lines
2112 bytes
mtucker@plainfield.bypass.com (Mark Tucker) wrote:

>Excuse my ignorance, I'm very new to using rexx and I'm just getting around to
>playing with arrays.  How does Rexx distinguish between an array named
>somthing like array_var.1 array_var.2 and the use of another variable to
>manipulate the variable such as array_var.loop_counter?  I'm coming from BASIC
>(sorry) experience.

>Tks,
>/\/\ark

It's like the rest of rexx - if the name is known, it is replaced by
its value (except the thing in front of the (first) dot). If its not
known, it is treated as if it had a value equivalent to its name, in
caps. Thus you can use:
   foo.1
or:
   x = 1
   foo.x
to treat a stem like an array. Or, you can use:
   emprec.name
   emprec.hiredate
to treat a stem like a record structure. Of course, this only works as
long a no one uses "name" or "hiredate" as a variable. If someone sets
name to "bob", then emprec.name becomes emprec."bob" (so to speak),
which almost certainly doesn't have a value, and is thus equivalent to
"emprec.bob" (as I recall).

To guard against this, some people use a numeric prefix as in:
   emprec.0name
   emprec.0hiredate
Oddly, the leading digit doesn't confuse rexx at all - rexx is
perfectly willing to let it be and treat it as "0NAME" or "0HIREDATE",
etc ... but variable names CANNOT start with digits, so you're
protected against someone inadvertently setting the variable and
changing the meaning of your statement.


- /\/\ark \/anTassel (mvantassel@teambca.com)
Re: REXX Arrays? Possible
#4780
Author: Bill Wymond
Date: Sat, 20 Apr 1996 09:45
28 lines
1513 bytes
In <zKadxsDmfW4V084yn@plainfield.bypass.com>, mtucker@plainfield.bypass.com (Mark Tucker) writes:
>Excuse my ignorance, I'm very new to using rexx and I'm just getting around to
>playing with arrays.  How does Rexx distinguish between an array named
>somthing like array_var.1 array_var.2 and the use of another variable to
>manipulate the variable such as array_var.loop_counter?  I'm coming from BASIC
>(sorry) experience.
>
>Tks,
>/\/\ark

Not sure to clearly understand your question.
Rexx doesn't need to 'distinguish' between the two variations above.
It _always_ resolves the tails if they form valid variablenames
and accesses the values given to the complete stem by the resolved stemname.
The only exception to this is the 'stem.' itself.
'stem' is never resolved.

So:

 stem.1 is seen by the interpreter as:
    stem.1

 if tail = 'anything', then stem.tail is seen as:
    stem.anything

Hope this helps,

Bill                                                      wymond@ibm.net
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads