Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,055 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Creating parameters for a function #73177
05/04/06 17:43
05/04/06 17:43
Joined: Dec 2003
Posts: 179
Chameleon_Man Offline OP
Member
Chameleon_Man  Offline OP
Member

Joined: Dec 2003
Posts: 179
Hey guys,

Whats the syntax for creating a function where you pass in the parameter? I'm used to C++, so when I declare function, I do it like this...

function MY_STUFF(var MY_VAR) { //blah }

or

function MY_STUFF(var& MY_VAR) { //blah }

...for passing by reference. Unfortunately I get a compile error. I must be doing something wrong! Help! Thanks a ton.

-Harb

Re: Creating parameters for a function [Re: Chameleon_Man] #73178
05/04/06 21:07
05/04/06 21:07
Joined: May 2005
Posts: 338
Brasil
Filipe Offline
Senior Member
Filipe  Offline
Senior Member

Joined: May 2005
Posts: 338
Brasil
in c-script you don't need the type of the parameter:

function MY_STUFF(/*var*/ MY_VAR) { //blah }

Re: Creating parameters for a function [Re: Filipe] #73179
05/04/06 21:12
05/04/06 21:12
Joined: Aug 2003
Posts: 7,440
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,440
Red Dwarf
you do it like this:

function testfunc(_variable)
{
temp = _variable;
}

or for arrays:

function testfunc2(&array)
{
temp.x=array[0];
temp.y=array[1];
temp.z=array[2];
}

note that i used _variable above instead of just "variable", just in case to make sure this isnt used by any normal variable, you can write "blah" aswell, but adding a _ before is recommended.


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1