Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
value parameter, variable parameter Posted by matter on 12 Nov 2012 at 6:22 AM
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
Report
Re: value parameter, variable parameter Posted by quikcarlx on 12 Nov 2012 at 11:05 AM
"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:
     {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 ); 




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.