Reaper Grimm
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > acs array as function parameter?
 
Author
All times are GMT. The time now is 18:38. Post New Thread    Post A Reply
gggmork
If you can make any sense of this post, congratulations


Posts: 2771
Registered: 06-07


I guess feeding an array to a function as an argument is a no no?

code:
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).

Old Post 12-21-10 03:13 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Graf Zahl
Why don't I have a custom title by now?!


Posts: 7734
Registered: 01-03


You guessed right. You can only pass integers as parameters to functions and scripts.

Old Post 12-21-10 07:43 #
Graf Zahl is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
gggmork
If you can make any sense of this post, congratulations


Posts: 2771
Registered: 06-07


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.

Last edited by gggmork on 12-21-10 at 08:35

Old Post 12-21-10 08:12 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Quasar
Moderator


Posts: 6037
Registered: 08-00



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.

Old Post 12-21-10 15:13 #
Quasar is online now Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 18:38. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > acs array as function parameter?

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.