Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (AndrewAMD, Quad, soulman3, Ayumi), 675 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
return more than 1 parameter #159741
10/08/07 19:49
10/08/07 19:49
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hi!
I have a little syntaxquestion:

If I return something with return I get the returned value like this:
temp = anothertest();

But now I want that the variable is returned where now temp stands:
anothertest(temp);

Is this possible with C-Skript?
Hope you understand what I mean
Thanks!

Dark_Samurai


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: return more than 1 parameter [Re: Dark_samurai] #159742
10/08/07 20:35
10/08/07 20:35
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Instead of using a return, use a global variable. Then just save whatever to that variable...


xXxGuitar511
- Programmer
Re: return more than 1 parameter [Re: Dark_samurai] #159743
10/08/07 21:39
10/08/07 21:39
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Quote:

But now I want that the variable is returned where now temp stands: anothertest(temp);




This is called "call by reference":

Quote:

//increases the incoming int by itself
void testFunc (int* in)
{
*in += *in;
}




Re: return more than 1 parameter [Re: HeelX] #159744
10/10/07 11:06
10/10/07 11:06
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Is this also possible with c-skript?

Dark_Samurai


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: return more than 1 parameter [Re: Dark_samurai] #159745
10/10/07 11:55
10/10/07 11:55
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline
User
bstudio  Offline
User

Joined: Aug 2006
Posts: 652
Netherlands
It should be. I reckon you don't have to define a filetype


BASIC programmers never die, they GOSUB and don't RETURN.
Re: return more than 1 parameter [Re: bstudio] #159746
10/10/07 12:14
10/10/07 12:14
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Yes, you just need to use a pointer (reference) to the var which should be changed by the function.
As far as I know this is done via the & sign:
Code:

function increase(&myVar)
{
myVar[0] += myVar[0];
}

function test_increase()
{
temp = 5;
increase(temp);
}



Re: return more than 1 parameter [Re: Xarthor] #159747
10/10/07 12:20
10/10/07 12:20
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline
User
bstudio  Offline
User

Joined: Aug 2006
Posts: 652
Netherlands
As far as I know the & sign is only used for arrays right? So for a normal variable it would be:
Code:

function increase(myVar)
{
myVar += myVar;
}

function test_increase()
{
temp = 5;
increase(temp);
}



Correct me if i'm wrong though


BASIC programmers never die, they GOSUB and don't RETURN.
Re: return more than 1 parameter [Re: bstudio] #159748
10/10/07 16:10
10/10/07 16:10
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Manual:
Quote:


Functions also accept pointers to arrays or to structs as parameters. In C-Script we prefix the parameter name by a "&" in order to indicate that a parameter is a var pointer instead of a single number. In lite-C however we indicate this like any other non-var parameter by preceding the parameter name by its var* type. If an array pointer is passed to a function, its elements can be accessed as usual through [..] indices:





I read that more than three times before I opened this thread but I didn't understood it... Now I know that it's exactly what I'm looking for

So Xarthor is right, you have to use the & sign.

Thanks very much for everyone who helped me!

Dark_Samurai


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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