Posts: 1,769
Threads: 410
Joined: Feb 2003
i keep getting an error in this code can someone spot it?
keeps giving me "Error (RT) in Macro: invalid index"
thanks
here's the array init.
ARRAY(str) e.create(0 0)
int x y z
,for y 0 3
,,d.get(c 2 20)
,,d.trim(" ")
,,e[y 1]=d
,,d.get(c 21 82)
,,d.trim(" ")
,,e[y 2]=d
,,d.get(c 83 128)
,,d.trim(" ")
,,e[y 3]=d
Posts: 12,092
Threads: 142
Joined: Dec 2002
why create(0 0) ?
Can be
ARRAY(str) e.create(3 4)
or
ARRAY(str) e.create(3 3)
...
e[y 0]=d
...
or
ARRAY(str) e.createlb(3 0 3 1)
or, if number of elements in right dimension initially is unknown
ARRAY(str) e.create(3 0)
...
e.redim(y+1) ;;resize right dimension
e[0 y]=d
...
Posts: 1,769
Threads: 410
Joined: Feb 2003
i dont know how many elements i will need in each dimention so i thought 0's would make it "expandable". will it expand without adding special code?
Posts: 12,092
Threads: 142
Joined: Dec 2002
No, to expand rightmost dimension, use redim. Other dimensions cannot be expanded.
Posts: 1,769
Threads: 410
Joined: Feb 2003
now i'm having a prob with a dimention error.
so here's what i'm thinking this does.
it creates a virtual spreadsheet with 3 columns (0,1, and 2) with as many rows as there are lines in str b (which is equal to z). then parses out one line at a time and a certian number of characters putting them into each of the 3 columns then moving down a row.
is that correct?
z=numlines(b)
ARRAY(str) e.create(z z z)
foreach(c b)
,if(!c.len)continue
,for y 0 z
,,d.get(c 2 19)
,,d.trim(" ")
,,e[y 1]=d
,,d.get(c 22 55)
,,d.trim(" ")
,,e[y 2]=d
,,d.get(c 82 45)
,,d.trim(" ")
,,e[y 3]=d
Posts: 12,092
Threads: 142
Joined: Dec 2002
If it is array of two dimensions, then create must have two arguments, not three. First argument is the number of elements in first dimension, second argument is the number of elements in second dimension (can be 0 if later you will use redim).
str b.getmacro("WinTypes")
str c d
int y z
z=numlines(b)
ARRAY(str) e.create(3 z) ;;3 columns, z rows
foreach(c b)
,if(!c.len)continue
,d.get(c 2 19)
,d.trim(" ")
,e[0 y]=d
,d.get(c 22 55)
,d.trim(" ")
,e[1 y]=d
,d.get(c 82 45)
,d.trim(" ")
,e[2 y]=d
,y+1
int i
for i 0 e.len
,out "''%s'' ''%s'' ''%s''" e[0 i] e[1 i] e[2 1]
,
Posts: 1,769
Threads: 410
Joined: Feb 2003
AAAahhhhh...."3 columns, z rows".....
i thought i was setting the number of rows in each dimention with each number! :roll:
well that should certianly change things!
thanks
|