Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,227 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Overgive parameters #302810
12/22/09 13:40
12/22/09 13:40
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
Ok, im sure, this is a stupid question, but i didnt understand the manuel/workshops about this.
Maybe someone can explain to me?

ok, i have a funktion, which is called from another funktion like this:

Code:
function test()
{
......
while(1)
{
if (on_mouse == 1)
{
calculate_a_var();
}
if (calculated_var == 1)
{
do something;
}
}
}



Ok, now i want to calculate a var, and give it back to function test.

Code:
function calculate_a_var()
{
var calculated_var

calculated_var = 1;
}



ok, if i wanna overgive the calculated_var to function test.

do i need to define the calculated_var in function test too?
and if i write

function calculate_a_var(calculated_var)

this way, is calculated_var overgiven to function test?

Thank you for all help.

Greetings Mike

Last edited by MikeS; 12/22/09 14:36.
Re: Overgive parameters [Re: MikeS] #302814
12/22/09 13:52
12/22/09 13:52
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline
Senior Member
MPQ  Offline
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
try:

return (calculated_var = 11);

Last edited by MPQ; 12/22/09 13:52.

new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: Overgive parameters [Re: MPQ] #302816
12/22/09 13:56
12/22/09 13:56
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
Ok, but do i need to define the calculated_var in function test to?

Greetings

Mike

Re: Overgive parameters [Re: MikeS] #302822
12/22/09 15:36
12/22/09 15:36
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline
Senior Member
Razoron  Offline
Senior Member

Joined: May 2009
Posts: 445
Peine, Germany
Make it like this:

Code:
function test()
{
var calculated_var;
.....
while(1)
{
if (on_mouse == 1)
{
}
if (calculate_a_var()==1)
{
do something;
}
}
}



You can rename calculated_var with anything. The name doesn't metter.

Last edited by Razoron; 12/22/09 15:37.
Re: Overgive parameters [Re: Razoron] #302825
12/22/09 15:54
12/22/09 15:54
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
no, does not work :-(

Greetings Mike

Re: Overgive parameters [Re: MikeS] #302836
12/22/09 16:56
12/22/09 16:56
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
You can use pointers to make changes to the original var, and not the copy...
Code:
function calculate_a_var(var* input)
{
*input= 1;
}


Now define a local var, and pass its memory address...
Code:
function test()
{
var calculated_var = 0;
while(1)
{
if (on_mouse == 1)
{
calculate_a_var(&calculated_var);
}
if (calculated_var == 1)
{
do something;
}
}
}



Re: Overgive parameters [Re: DJBMASTER] #302838
12/22/09 17:00
12/22/09 17:00
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
K, ill try.

greetings

Mike

Re: Overgive parameters [Re: MikeS] #302862
12/22/09 21:06
12/22/09 21:06
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Code:
function calculate_a_var()
{
   var calculated_var
   ......
   calculated_var = 1;
   ......
   return(calculated_var);
}
//
//
function test()
{
   ......
   var returned_var = 0;
   while(1)
   {
      if (on_mouse == 1)
      {
         returned_var = calculate_a_var();
      }
      if (returned_var == 1)
      {
         do something;
      }
   }
}

OR (with this calculate_a_var)

function test()
{
   ......
   while(1)
   {
      if ( (on_mouse == 1) && (calculate_a_var() == 1) )
      {
         do something;
      }
      wait(1);
   }
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Overgive parameters [Re: MikeS] #302948
12/23/09 20:57
12/23/09 20:57
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
Just a short advice: use the word "pass" instead of "overgive".
I stared for a long minute while i understood what do you want.
Sorry for the correction.

Re: Overgive parameters [Re: Aku_Aku] #303215
12/26/09 21:45
12/26/09 21:45
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
Hey, thanks EvilSOB,

your first example worked very well.

Great.

Greetings

Mike


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