REF(parameter passed by reference)

Top  Previous  Next

 

REF datatype

 

The REF keyword is added to Clarion# to provide compatibility with other .NET languages. It’s used to mark a parameter as "passed by reference". The REF keyword can be used before the type name in the parameter declaration.

 

Example 1:

 

MyMethod PROCEDURE(REF LONG I=10)

 

Example 2:

 

!*****************

 PROGRAM

 NAMESPACE(ref_test)

 USING System

 MAP

TestOut PROCEDURE(REF CHAR i),INT32

 END

 

i CHAR

 

 CODE

  Console.WriteLine(TestOut( i))

  Console.WriteLine(i)

  System.Console.ReadKey()

 

TestOut  PROCEDURE(CHAR i)

 CODE

  i='x'

  RETURN -1

 

!  Output:

!  -1

!   x