Page 1 of 1

Array Find

Posted: Sat Jul 18, 2015 2:09 pm
by Vayeco Dynn
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.

Re: Array Find

Posted: Sat Jul 18, 2015 6:12 pm
by PeteSampras
array isnt a valid variable, so none of that would work

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

Re: Array Find

Posted: Sat Jul 18, 2015 6:54 pm
by Vayeco Dynn
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?

Re: Array Find

Posted: Sat Jul 18, 2015 11:58 pm
by PeteSampras
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