value parameter, variable parameter - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

value parameter, variable parameter

mattermatter Posts: 3Member
Hello

I`m trying to understand what this is all about "value parameter" and
"variable parameter" in procedures.

Let`s say I have some procedure: proc1(a,b :integer)

and some operations on a and b (maybe together with other variables x,y,z)
when does it affect the outcome of the procedure at choosing a,b as value parameter or variable parameter?

I`m really confused about this and hope you can help me!!!

Thanks
matter

Comments

  • quikcarlxquikcarlx Hollywood, FlPosts: 26Member
    "Value parameter(s)" are passed to procedures and functions as static value(s). That means you
    send to the procedure or function a value (it's put on the call stack as the value). "Variable
    parameter(s)" are passed to procedures and functions as dynamic and are the address(es) of the
    variable. With the address you can pass values to and from the procedure(s) or function(s). As
    examples:
    [code]
    {value passing}

    procedure valproc ( a, b : integer ); { can be used in the procedure, but nothing
    can be sent back }

    {variable passing}

    procedure varproc ( var x, y : integer ); { can be used and can be sent back with
    the same or different values }
    {both types}

    procedure bothproc ( a, b : integer; var x, y : integer );
    [/code]
Sign In or Register to comment.