|
|
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
OP
Serious User
|
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]
#159743
10/08/07 21:39
10/08/07 21:39
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
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
OP
Serious User
|
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
User
|
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
Expert
|
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
User
|
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.
|
|
|
|