- Posts: 241
- Thank you received: 14
Faking a 2D array and % symbols on output
- krell
-
Topic Author
- Offline
- Elite Member
-
I've managed to cobble together a script that fakes a 2-dimensional array. Unformatted and raw from my text editor: (the []'s aren't required, but just a convention I sort of like)
set i 0
set j 0
set m 0
set n 0
if count == %cmd%
while %i% <= 5
set array[%i%][j] %m%
while %j% <= 5
set array[i][%j%] %n%
eval n %n% + 1
eval j %j% + 1
done
eval m %m% + 1
eval i %i% + 1
set j 0
done
set i 0
set j 0
while %i% <= 5
while %j% <= 5
%echo% %%%array[%%i%%][%%j%%]%%%
eval j %j% + 1
done
eval i %i% + 1
set j 0
done
else
return 0
end
Which seems to work except I get %'s in the output which I really don't want.
#LOG: LOGGING OUTPUT TO 'fake2dlist.log' FILESIZE: 0
Jess the test MOB. has arrived.
set krell level 20
Krell's level set to 20.
count
%00%
%01%
%02%
%03%
%04%
%05%
%10%
%11%
%12%
%13%
%14%
%15%
%20%
%21%
%22%
%23%
%24%
%25%
%30%
%31%
%32%
%33%
%34%
%35%
%40%
%41%
%42%
%43%
%44%
%45%
%50%
%51%
%52%
%53%
%54%
%55%
Edgar the test MOB leaves north.
#log off
Is there any way to get rid of them and still get the output I want? I've tried varying the level of %'s on the variable, but it either puts the name of the list or just the names i and j.
Please Log in or Create an account to join the conversation.
- Parnassus
- Offline
- Administrator
-
- Posts: 366
- Thank you received: 54
I'm not sure if this is the problem because, you know, I have some problems understanding the complex stuff but I hope you'll find it helpful anyway. And if not, hey, it gives people a chance to see it after 6 years because it's important.
Please Log in or Create an account to join the conversation.
- krell
-
Topic Author
- Offline
- Elite Member
-
- Posts: 241
- Thank you received: 14
Hope to see you around more, Parna. Miss you.
Please Log in or Create an account to join the conversation.
- krell
-
Topic Author
- Offline
- Elite Member
-
- Posts: 241
- Thank you received: 14
Parnassus wrote: Thomas has written up a wonderful explanation of %s
Yep, that fixed it. Almost exactly as Thomas explained it. I had to track how many levels the percent symbol was at, and I had to use more eval statements then I originally wanted. Last night I wasn't able to wrap my head around it, but now it works. Thanks again, Parna. You're the best.
set i 0
set j 0
set m 0
set n 0
if count == %cmd%
while %i% <= 5
set array[%i%][j] %m%
while %j% <= 5
set array[i][%j%] %n%
eval n %n% + 1
eval j %j% + 1
done
eval m %m% + 1
eval i %i% + 1
set j 0
done
set i 0
set j 0
while %i% <= 5
while %j% <= 5
eval temp %%array[%%%i%%][%%j%%]%%
eval temp2 %temp%
%echo% %temp2%
eval j %j% + 1
done
eval i %i% + 1
set j 0
done
else
return 0
end
Output
00
01
02
03
04
05
10
11
12
13
14
15
20
21
22
23
24
25
30
31
32
33
34
35
40
41
42
43
44
45
50
51
52
53
54
55
Please Log in or Create an account to join the conversation.
- Parnassus
- Offline
- Administrator
-
- Posts: 366
- Thank you received: 54
Please Log in or Create an account to join the conversation.