Info on an array

For questions regarding conversion of scripts from the old, parm style to the new MQ2Data format. Conversion questions only!

Moderator: MacroQuest Developers

Furor
a lesser mummy
a lesser mummy
Posts: 44
Joined: Sun Nov 30, 2003 8:25 pm

Info on an array

Post by Furor » Thu May 06, 2004 6:35 pm

Can you still use an array that holds different vars?

IE holds an int in one part and holds a string in another.

Thanks
Furor

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Thu May 06, 2004 7:24 pm

Wait.. the answer to your second question is no.. but.. the answer to your first question is yes.

Arrays can only be made to hold one type. Previously, there were no "types", everything was a string. Now, there are types. Not everything is a string. So, one way to do it is to make your array hold strings, and it can magically hold ints in the form of strings.. e.g. the int 1234 is stored inthe array as a string containing "1234" .. like, wow! The other way is to use an "array of pointers"... pointer isnt really the term, but let me explain.

At the bottom of the MQ2DataVars reference is a section titled "Tricksy Hobbitses" something or other. It explains how a string can store the name of a variable, and then referenced later.

For example.

Code: Select all

/declare mystring string local My String
/declare mypointer string local mystring
/echo ${${mypointer}}
The echoed value is "My String". What happens is the inside ${} gets parsed, making "${mystring}" and then the outside ${} gets parsed, making "My String", the value of mystring.

This applies equally to arrays:

Code: Select all

/declare mystring1 string local My String A
/declare mystring2 string local My String B
/declare myarray[2] string local
/varset myarray[1] mystring1
/varset myarray[2] mystring2
/echo ${${myarray[1]}}
/echo ${${myarray[2]}}
The output is:
My String A
My String B


Hope this helps.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

Furor
a lesser mummy
a lesser mummy
Posts: 44
Joined: Sun Nov 30, 2003 8:25 pm

Post by Furor » Thu May 06, 2004 10:03 pm

Thank you Lax as always great work and great help

Furor