Arrays

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Arrays

Post by I R monk » Mon Dec 16, 2002 11:09 pm

can any one share some info on this subject or point me at any write ups on it?

Looking for 3 main points, first is there a limit on the number of arrays you can use in a single macro?

2nd when setting arrays for text info do you need to enclose it in "" only if its a multi part word, such as Spirit of wolf?

3rd is the limit to a single array 0 to 9?

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Tue Dec 17, 2002 12:04 am

Salutations,
1) 99
2) technically yes, but if you enclose all strings no1 will notice
3) dunno what you mean...

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Post by I R monk » Tue Dec 17, 2002 10:15 am

Thanks L124RD, In reguards to the 3rd
I might be off base here so let me provide a few examples
a(0,0) to a(0,99)
to a(99,0) to a(99,99)
an array is defined by a()
then the a(0,#) would be the first array and a(0,0) would be the first record in the first array? and an array is basicly just a table for storing information.

So you can have up to 99 arrays ie a(0,#) to a(99,#) guess my question is how many records per array?

Also hats off to the coder who's example showed me how to define each array. makes it a lot easyer to keep track of. IE

#define aClericSpells 0
a(aClericSpells,0)
a(aClericSpells,1)

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Tue Dec 17, 2002 12:02 pm

Dont know if you meant me there I R monk but ill take credit anyway :-)

In answer to your question you can have 99 arrays each of 99 items or if your thinking of a table it would be 99 rows and 99 columns i.e


Code: Select all


a(0,0)   a(1,0)	    a(2,0)      a(3,0)	...  a(99,0)
a(0,1)   a(1,1)	    a(2,1)      a(3,1)	...  a(99,1)
a(0,2)   a(1,2)	    a(2,2)      a(3,2)	...  a(99,2)
a(0,3)   a(1,3)	    a(2,3)      a(3,3)	...  a(99,3)
.           .	       .           .	...  .
.           .	       .           .	...  .
.           .	       .           .	...  .
a(0,99)  a(1,99)    a(2,99)     a(3,99) ...  a(99,99)
Fippy

This is my girl. But Rizwank had her first :-)
[img]http://www.btinternet.com/~artanor/images/fairy_bounce09.gif[/img]

I R monk
orc pawn
orc pawn
Posts: 28
Joined: Tue Dec 10, 2002 4:29 pm

Post by I R monk » Tue Dec 17, 2002 12:29 pm

Thats the Ticket! thanks for the help, that will go a long way in completing my PowerLevels.mac,

lifewolf
a ghoul
a ghoul
Posts: 143
Joined: Fri Oct 18, 2002 6:29 pm

Post by lifewolf » Thu Dec 19, 2002 11:06 am

if you somehow manage to need more space, or would rather keep things organized differently, try abusing local vars of a sub

Code: Select all

| Basic array #101
| Useage:
| /call AditionalArray read <#>  -- Returns $l## variable
| /call AditionalArray write <#> "Data"  -- Stores $l## variable
| /call AditionalArray  -- Sets all variables to NULL


Sub AdditionalArray
   /if "$p1"==NULL {
      /for p1 0 to 99
      /varset l$p1 NULL
   }
   /if "$p1"~~"read"  /return "$l$p2"
   /if "$p1"~~"write" /varset l$p2 "$p3"
   /return