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 assignfield 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.00 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 Operator

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

Price <== 4.99

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

Keep in mind that the <== operator 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).

What is the Current Field?

If there is code associated with the modified field, that code may assume that the modified 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.