Manipulating variables by reference

This example shows how you can pass variables as a reference and change its values.

Source:

Screenshot:

$ hbrun byref.prg

Managing LOCAL variables by reference
In Main() before ref1() x=          0
 In ref1() before ref2() =          1
  In ref2() before ref3() =          2
   In ref3() before ref4() =          3
    In ref4() =          4
   In ref3() after ref4() =          3
  In ref2() after ref3() =          3
 In ref1() after ref2() =          3
 In Main() after ref1() x=          3
Managing STATIC variables by reference
In Main() before ref1() s=         10
 In ref1() before ref2() =         11
  In ref2() before ref3() =         12
   In ref3() before ref4() =         13
    In ref4() =         14
   In ref3() after ref4() =         13
  In ref2() after ref3() =         13
 In ref1() after ref2() =         13
 In Main() after ref1() s=         13

How to build/run:

To learn how to build/run this example, see this page.