Call By Reference

From DataFlex Wiki
Revision as of 11:11, 24 February 2019 by Wil (talk | contribs) (add syntax highlighting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Call By Reference or Pass By Reference is a technique where arguments that are passed into a procedure or function are the actual memory resident values from the calling procedure. When the value of an argument passed by reference is changed in the child procedure, the value of the argument in the parent procedure is also changed, since technically they are the same arguement.

Example

The following code passes a reference to the argument sName in to the procedure DoCall.

String sName

Procedure DoCall String ByRef sName 
    showln "name:" sName
    Move "B" to sName
End_Procedure


Move "A" to sName
Send DoCall(&sName)
showln "name:" sName

The output window would display:

name:A
name:B