Welcome!

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

SignUp Now!

Parsing an array variable to an array does not work

Oct
31
0
I have array m filled with many rows in 2 columns. I want to compare a string with the content of each row in the first column. That works without any problem. I build a DO-loop to increment the row number and inside the loop I compare the string with the content of the first column in each row:
(%r = row number)
(%m = array m)

DO r = 0 TO %@DEC[%@arrayinfo[m,1]] BY 1 IFF %@WILD["%string%",*%m[%r%,0]*] == 1 THEN ECHO Found ELSE Echo Not found ENDIFF ENDDO

This DO-loop works perfect. Now, I have 2 arrays: array m and t and I want to compare a string with the first column in each row of each array. I build a second DO-loop around the first DO-loop:
(%a = array)
(%r = row number)

DO a IN /L t m DO r = 0 TO %@DEC[%@arrayinfo[%a,1]] BY 1 IFF %@WILD["%string%",*%%a[%r%,0]*] == 1 THEN ECHO Found ELSE Echo Not found ENDIFF ENDDO ENDDO

Variable a become “t” but the parsing does not work. I experimented with more % signs, but I can’t get it to work.
 
In a nutshell ...

Code:
v:\> setarray a[2] & set a[0]=TRUE & set a[1]=FALSE

v:\> set arrayname=a

v:\> echo %[arrayname[0]]
TRUE

v:\> echo %[arrayname[1]]
FALSE
 
Also (with the set-up above),

Code:
v:\> do index=0 to 1 ( echo %[arrayname[%index]] )
TRUE
FALSE
 
Thanks Vefatica for your input.
I couldn't get the code working:
IFF %@WILD["%string%",*%[a[%r%,0]]*] == 1 THEN
I'll build a test programm to understand the difficulty.
 
I don't know. This seems to work.

Code:
v:\> setarray a[4,2]

v:\> set a[0,0]=? & set a[1,0]=?? & set a[2,0]=??? & set a[3,0]=????

v:\> set string=xxxx

v:\> do name in /L a ( do row=0 to 3 ( if %@wild[%string,%[name[%row,0]]] == 1 echo YES (row %row) ))
YES (row 3)
 
Thanks Vetatica,

I have build a test.btm with:
IFF %@WILD["%string%",*%[a[%r%,0]]*] == 1 THEN
It ran without any problem.
I applied the same fix to my batchfile again and it worked this time without any problem.
So, the bug disappeared. Must be programmerdfailure.
Thanks.
 
Back
Top
[FOX] Ultimate Translator
Translate