Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Kenny77
18
Years of Service
User Offline
Joined: 7th Oct 2006
Location:
Posted: 24th Oct 2006 00:13
Can someone explain how values are passed in functions? I have always had trouble with this, even is C++, thanks.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 24th Oct 2006 00:54
Easy, really really easy.



Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Oct 2006 00:59
Functions can return only one variable.

Kenny77
18
Years of Service
User Offline
Joined: 7th Oct 2006
Location:
Posted: 24th Oct 2006 01:58 Edited at: 24th Oct 2006 01:59
Ok, I think I made it more complicated then it needed to be. Mostly because I'm used to C++.
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 24th Oct 2006 02:07 Edited at: 24th Oct 2006 02:11
Here's a mini tutorial

In the function declaration, write the names of the variables that will receive values. Then, in the function calls, write the actual values in place of the variables.

Like this:

Passing variables to a function



Receiving variables in a function



When the variables are being sent to the function, they are called parameters. When they are being received, they are called arguments.

Confucius Say...
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 25th Oct 2006 03:49 Edited at: 25th Oct 2006 03:55
Variables are passed by reference, or by value. DBPro passes by value, so you are working with a copy of the variable, and not the actual variable.

In C/C++, passing by reference is more popular. You work with the actual variable in that case, but your access to it is through a pointer.

Memblocks are how you can do a little of that type of programming in DBPro, since they use pointers, sort of.

To answer what I think is your question:

When passing by value, the variable's content is pushed onto the programs' local stack, along with all other parameters, and the return address. This is called a stack frame. The variable's content is not changed.

When passing by reference, the address of the variable is pushed onto the stack frame, and the return address, as well.

The right to left, or left to right order of parameters is dependent upon the language being used. C/C++ is left to right; BASIC is right to left.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 25th Oct 2006 04:27 Edited at: 25th Oct 2006 04:27

Login to post a reply

Server time is: 2024-11-27 03:32:42
Your offset time is: 2024-11-27 03:32:42