Array Find

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

Vayeco Dynn
a ghoul
a ghoul
Posts: 113
Joined: Wed Aug 25, 2004 3:00 am

Array Find

Post by Vayeco Dynn » Sat Jul 18, 2015 2:09 pm

Okay, is this code inherently flawed?

Code: Select all

|--------------------------------------------------------------------------------
|SUB: InArrayPartial
|--------------------------------------------------------------------------------
Sub InArrayPartial(string Needle, array Haystack)

	/declare i int

	/for i 1 to ${Haystack.Size}
	
		/if (${Needle.Find[${Haystack[i]}]}) {
		
			/return TRUE
		
		}
	
	/next i

/return FALSE
It seems to crash EQ every time I try to call it, passing in a string and an array as parameters.

PeteSampras
a snow griffon
a snow griffon
Posts: 322
Joined: Sat Dec 15, 2007 8:56 pm

Re: Array Find

Post by PeteSampras » Sat Jul 18, 2015 6:12 pm

array isnt a valid variable, so none of that would work

also, there isnt a lower/upper bound (size) option either.

Vayeco Dynn
a ghoul
a ghoul
Posts: 113
Joined: Wed Aug 25, 2004 3:00 am

Re: Array Find

Post by Vayeco Dynn » Sat Jul 18, 2015 6:54 pm

If you define the parameters of a Sub, the parameters can be of any data type that exists in MQ2DataVars
http://www.macroquest2.com/includes/was ... p#refarray

Is array not a data type and does it not have a Size member?

PeteSampras
a snow griffon
a snow griffon
Posts: 322
Joined: Sat Dec 15, 2007 8:56 pm

Re: Array Find

Post by PeteSampras » Sat Jul 18, 2015 11:58 pm

it is a datatype that you can use within the c/c++ code but not one that is declarable within a macro.

any types that you use outside of string/int/float/timer/char/bool end up returning NULL/default values when you access them. the macro code .cpp needs updated probably.

/declare string whatever[10,20] 0

that would create an array called "whatever" that is 10 x 20 with default values of a string "0"

/varset whatever[1,2] 12345