gggmork Posted December 21, 2010 I guess feeding an array to a function as an argument is a no no? int myarray[2] = {5,2}; script 1 open{ while (1){ printThis(myarray); } } error says: missing '[' But if I change the first line to int myvar = 5; there's no errors (printThis is a simple test function not shown). 0 Share this post Link to post
Graf Zahl Posted December 21, 2010 You guessed right. You can only pass integers as parameters to functions and scripts. 0 Share this post Link to post
gggmork Posted December 21, 2010 Aw nuts, thanks for the confirmation. Edit: actually I'm probably an idiot because arrays have to be global anyway (declared outside of scripts).. so functions can probably access them without needing them as a parameter. 0 Share this post Link to post
Quasar Posted December 21, 2010 gggmork said:Aw nuts, thanks for the confirmation. Edit: actually I'm probably an idiot because arrays have to be global anyway (declared outside of scripts).. so functions can probably access them without needing them as a parameter. Probably what you'll have to do then is define constants which indicate which array your function should use and then use a large switch or if/else chain to pick the proper array. Then you can pass the constant to the function instead of the array itself, kinda like a skank version of a hash key or pointer. 0 Share this post Link to post