User Tools

Site Tools

Navigation:  Language Reference > 11 - Assignments > Assignment Statements >====== Reference Assignments ====== Previous pageReturn to chapter overviewNext page


destination &= Source


destination The label of a reference variable.
source This may be:
·The label of a variable or data structure of the same type as referenced by the destination.
·The label of another reference variable of the same type as the destination.
·A call to a PROCEDURE which returns the data type the destination will receive.
·An expression (yielding a LONG value, such as the return value of the ADDRESS procedure) that defines the memory address of a variable of the same type as referenced by the destination (which must be a reference to any simple data type except STRING, CSTRING, PSTRING, or GROUP).
·The NULL built-in variable.

The &= sign executes a reference assignment statement. A reference assignment statement assigns a reference to the source variable to the destination reference variable. When used in a conditional expression (such as an IF statement), a reference assignment statement determines reference equality (are the two reference variables “pointing at” the same thing?).

Depending upon the data type being referenced, the destination reference variable may receive the source's memory address, or a more complex internal data structure (describing the location and type of source data).

When the source is the built-in variable NULL, the reference assignment statement may either clear the destination reference variable, or detect an unreferenced reference variable (when the reference assignment statement is placed in a conditional expression). This is the recommended technique for testing for NULL in Clarion# programs.

The declarations of the destination reference variable and its source must match exactly (unless the destination is declared as an ANY variable); reference assignment does not perform automatic type conversion. For example, a reference assignment statement to a destination declared as &QUEUE must have a source that is either another &QUEUE reference variable or the label of a QUEUE structure. However, if the destination is a reference to a string (&STRING), the source may also be a data structure that is normally treated as string data when addressed as a single unit (GROUP, RECORD, QUEUE, MEMO).

Casting (i.e., converting the value of a token from one type of data to another) of the address to a reference variable is not valid if the target reference variable is of the &STRING, &CSTRING, &PSTRING and &GROUP types. Reference variables of these types are not just address specific, but contain additional information.

If the destination reference variable is declared as an ANY variable, the source cannot be:

·a variable of &WINDOW, &REPORT, &FILE, &VIEW, &KEY, &BLOB, named-CLASS, reference-to-named-CLASS and reference-to-named-INTERFACE types

·a call to a PROCEDURE which returns a result of *WINDOW, *REPORT, *FILE, *VIEW, *KEY, named- CLASS or named-INTERFACE types

·a call to a PROCEDURE with the RAW attribute which returns a result of ?, *? or *STRING types

·an expression returning a LONG value.


In Clarion# (Clarion.NET), reference assignments to objects are no longer required. Use the equal operator (=) for all reference type assignments. See the New in Clarion# topic for more information.


Queue1  QUEUE

ShortVar  SHORT

LongVar1  LONG

LongVar2  LONG


QueueRef  &QUEUE               !Reference a QUEUE, only

Queue1Ref &Queue1              !Reference to a QUEUE defined exactly as Queue1, only

LongRef   &LONG                !Reference a LONG, only

LongRef2  &LONG                !Reference a LONG, only


QueueRef &= Queue1            !Assign QUEUE reference

Queue1Ref &= Queue1           !Assign QUEUE reference

IF Queue1Ref &= QueueRef      !Are they referencing the same QUEUE?

 MESSAGE('Both Pointing at same QUEUE')


IF SomeCondition              !Evaluate some condition

 LongRef &= Queue1.LongVar1   !and reference an appropriate variable


 LongRef &= Queue1.LongVar2


LongRef += 1                  !Increment either LongVar1 or LongVar2

                              !depending upon which variable is referenced

IF LongRef2 &= NULL           !Detect unreferenced reference variable and

 LongRef2 &= LongRef          !create a second reference to the same data


LongRef &= ADDRESS(Queue1.LongVar1)   !Reference assign the address of

                                      !a simple data type

See Also:

Reference Variables



reference_assignments.htm.txt · Last modified: 2021/04/15 15:57 (external edit)