assignfieldwithsideeffects
FIELD
,
VALUE

The assignfieldwithsideeffects statement performs an assignment, much like an equals sign or the assign statement. However, the assignfieldwithsideeffects statement only performs the assignment to a database field, not to any variable. After performing the assignment, it will run any side effects associated with the field, including formulas and code associated with the field.


Parameters

This statement has two parameters:

field – is the name of the field that you want to modify.

value – calculates the value that will be placed into the field in the active record.


Description

This statement performs an assignment, much like an equals sign or the assign statement. However, the assignfieldwithsideeffects statement only performs the assignment to a database field, not to any variable. After performing the assignment, it will run any side effects associated with the field, including formulas and code associated with the field.

The procedure below will assign the value 4.99 to the Price field.

assignfieldwithsideeffects Price,4.99

It will then run any formulas or code associated with this field. For example, if there is a field named Total with the formula

Qty*Price

the Total field will be updated with the 4.99 times the quantity. Basically Panorama will behave just as if you had manually entered data into the Price field.

The <== Assignment Operation

To save typing, you can use the <== operation instead of the assignfieldwithsideeffects statement. Here is the same example as above, but rewritten with the <== operation.

Price <== 4.99

Note: In Panorama 6 and earlier, this action was performed with the == operation. The == operation no longer works in Panorama X, you must use <==.

Keep in mind that the <== operation only works with fields in the current database, you cannot use it to assign a value to a variable (use a regular = assignment for variables).

Note that an operation is not an operator. An operator is a token that takes a value on the left and a value on the right, and combines them into a new value (for example add or subtract). That is not what <== does, instead it assigns the value on the right to the field or variable on the left. Also, operators can be placed anywhere within a formula, but <== can only be used at the beginning of a statement, and it can only be used once within a statement, you can’t say a <== b <== x+y.

What is the Current Field?

If there is code associated with the modified field, that code may assume that the modified field is the current field. That will always be the case when data is entered manually. When assignfieldwithsideeffects or the <== operator is used, however, that may not be the case. Consider this code:

field Date
Price <== 12

Now suppose that the Price field has this code attached to it:

sortup

If you manually enter a new price, it will automatically sort up the Price field. (I’m not sure why you would ever do that, but it’s a simple example.)

However, if you run the code example above, it will sort the Date field instead of the Price field, because the Date field is the current field. So if you are going to use assignfieldwithsideeffects or <== be careful not to assume that the modified field is the same as the current field.


See Also


History

VersionStatusNotes
10.0NewNew in this version, but similar to the == operator in Panorama 6.