Faking a 2D array and % symbols on output

  • Krell
  • Krell's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
4 days 22 hours ago #8568 by Krell
Hey all,

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.

More
3 days 9 hours ago #8569 by Parnassus
Replied by Parnassus on topic Faking a 2D array and % symbols on output
Thomas has written up a wonderful explanation of %s .

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.
The following user(s) said Thank You: Krell

Please Log in or Create an account to join the conversation.

  • Krell
  • Krell's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
3 days 7 hours ago #8570 by Krell
Replied by Krell on topic Faking a 2D array and % symbols on output
I'll have to mull this over, just trying to apply it without thinking about the implication thoroughly is only tripping me up. But yeah, I do seem to recall this.

Hope to see you around more, Parna. Miss you.

Please Log in or Create an account to join the conversation.

  • Krell
  • Krell's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
3 days 31 minutes ago #8571 by Krell
Replied by Krell on topic Faking a 2D array and % symbols on output

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 level's 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.

Time to create page: 0.236 seconds