Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 8 Using Expressions and Operators : Assignment Operator

Assignment Operator
The rules language uses the equal sign (=) as the assignment operator.
Valid Assignments
The following chart shows which fields and values with the following semantic data types can be assigned to each other. In each case, the semantic data type of the result is the semantic data type of the left operand, unless the left operand is a local variable. If the left operand is a local variable, the semantic data type of the result is the semantic type of the right operand. Y indicates a valid operation.
An assignment of a string field to a date field can cause unexpected results if the default date format of your installation contains a two-digit year, for example, YYDDD or YYWW.
Types of Assignment Statements
Use assignment statements to assign values to fields or to local variables. There are two kinds of assignment statements:
Syntax of Assignment Statements
<assignment target> = <expression>
<assign by name>
Simple Assignment of a Value
In simple assignment, a single value is assigned to a field of a table or to a local variable.
Syntax
<assignment target> ::=
   <field of a table>
   <local name>
Examples
Two examples of simple assignment statements are:
CARS.PRICE = (PRICES.BASE + PRICES.SHIPPING)* TAXES.RETAIL;
AMOUNT = PRINCIPAL * (1 + INTEREST) ** YEARS;
Assigning Values by Name
In assignment-by-name, the field values of the table on the right are assigned to identically named fields of the table on the left. The field names are replaced with the asterisk symbol (*) for both the source and target tables.
Syntax
<table reference>.* =<table reference>.*
<table reference>.* = NULL
Example
INPUTORDERS.* = ORDERS.* ;
Assignment Relationship
One use of assignment-by-name assigns the values of fields of a screen table to fields of a data table, or vice versa. The following illustrates the assignment relationship between the screen fields in the screen table INPUTORDERS and the fields in the ORDERS table, as viewed in a user’s application:
Initializing All the Fields of a Table
Assignment-by-name is a convenient way to initialize all the fields of a table. For example:
ORDERS.* = NULL;
This statement initializes all the fields in the ORDERS table to null values.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved