Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What means parameters
Message
From
29/04/2007 11:15:41
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01220881
Message ID:
01220892
Views:
19
>In my function I got the message missing parameters
>
>Then I looked into another function I saw the parameters:
>
>*****************************************************************
>LPARAMETERS tcSource, tcDestination, tcAction, tlUserCanceled
>*****************************************************************
>
>What are parameters ?
>Are they variables ?
>
>Could anybody explain ? because I never used them before
>
>Moises

A function or procedure is a bit of code that can be called over and over again, to do some specific task. (FUNCTION and PROCEDURE is the same in VFP.)

A function might require some data to work with. This data is passed through parameters.

Here is a sample function that calculates the volume of a sphere. As data, it requires the radius of the sphere. I am also including a command that calls (or invokes) the function.
* Function is called here.
* The number 3 is passed as a parameter, i.e., as data to the function.
* The return value of the function is shown on screen - it might
* also be assigned to a variable, or included in further calculations.
? SphereVolume(3)

function SphereVolume(tnRadius)
  return 4 / 3 * pi() * tnRadius ^ 3
endfunc

* Alternative syntax:
* function SphereVolume
*   lparameters tnRadius
*   return 4/ 3 * pi() * tnRadius ^ 3
* endfunc
In the example:
  • 3 is passed as a parameter.
  • The function receives this to the variable tnRadius.
  • The function does some calculations with this value.
  • The function returns a value.
  • The entire function call can be used in more complex expressions, for example: x = SphereVolume(lnRadius) * 10 to get the volume of 10 identical spheres. When using a function this way, the function is evaluated, and the resulting value (the value returned by the function) is replaced in the expression.
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Previous
    Next
    Reply
    Map
    View

    Click here to load this message in the networking platform