Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done DO x in /A(rray) array_name ...

May
12,845
164
I've been using arrays a lot and I'm tired of typing
Code:
do i=0 to %@dec[%@arrayinfo[array_name,1]]
and later having to refer to %array_name[%i].

[And I don't know if you can overload "/A".]

But it would be very convenient to be able to process a 1-D array like this.
Code:
do x in /A array_name ...
and later refer to %x.
 
How about:
Code:
rem  Any array:
DO x IN AROWS arrayname

rem  Array with at least two dimensions:
DO x IN ACOLS arrayname

This is all just syntax sugar. It doesn't have to be implemented by Rex. A plugin can massage command parameters. Or you could write an alias or two.
 
How about:
Code:
rem  Any array:
DO x IN AROWS arrayname

rem  Array with at least two dimensions:
DO x IN ACOLS arrayname

This is all just syntax sugar. It doesn't have to be implemented by Rex. A plugin can massage command parameters. Or you could write an alias or two.
1-D would be fine with me and I suspect relatively easy compared to that one. If /A(rray) isn't available, I like /V(ector); after all a vector is a 1xN array.
 
I think just
Code:
DO x IN %[array]
…
ENDDO
should work.
Or add @ARRAY[] variable function for that purpose.
It doesn't.
Code:
v:\> setarray a[10] & do i=0 to 9 (set a[%i]=%i)

v:\> do x in %[a] echo %x
Usage : DO [n | FOREVER]

And I wouldn't expect it to work. "%[a]" is a reference to the environment variable whose name is "a".
Code:
v:\> set a=2

v:\> echo %[a]
2

What would @ARRAY[] do?
 

Similar threads

Back
Top