3. Statements : OpenROAD Language Statements : Assignment Statement : Reference Assignment Statements
 
Share this page                  
Reference Assignment Statements
A reference assignment statement redirects either a reference variable or an array variable. A reference variable is a pointer to an object. An array variable points to a set of reference variables, which points to a set of objects. When you assign a new value to a reference variable or array variable, you point the variable to a new object or set of objects, respectively.
Valid assignments for a reference variable include:
Another reference variable. For example:
newcustomer = customer;
A row reference in a dynamic array. For example:
newcustomer = client[5];
A null. For example:
newcustomer = null;
If two (or more) reference variables point to the same object, you can use either variable to access the individual attributes of the object. Any changes you make are visible through both variables. (If the object's attribute values are displayed in a frame, changes become visible when the event block completes or the form is refreshed.) Similarly, if two array variables point to the same set of objects, you can access the objects or individual object attributes through either variable, and any changes are visible to both variables.
When you assign one reference variable to another, the system class for the reference variable on the right-hand side of the assignment must be the same as, or a subclass of, the variable on the left. In the following example, firstfield is a reference variable of type ActiveField and surname is a reference variable of type EntryField, which is a subclass of ActiveField:
firstfield = surname;
When you assign a null to a reference variable, the variable no longer points to any object.
You can also redirect an array variable. For example, in the following statement both client and old_customers are array variables:
client = old_customers;
The array variable, client, now points to the same array as the old_customers array variable. The declared system class for the array on the right side must be the same as, or a subclass of, the declared system class for the array on the left.
As with reference variables, you can assign a null to an array variable.
Because individual rows of an array are reference variables, you can use individual row references in assignment statements. For example:
client[5] = newcustomer;