assignfieldwithsideeffects
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

- assign -- assigns a value to a field or variable.
- assignfield -- 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.
- assignfileglobal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignfileglobal* statement only performs the assignment to a fileglobal variable.
- assignglobal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignglobal* statement only performs the assignment to a global variable.
- assignlocal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignlocal* statement only performs the assignment to a local variable.
- assignwindowglobal -- performs an assignment, much like an equals sign or the assign statement. However, the *assignwindowglobal* statement only performs the assignment to a windowglobal variable.
- define -- performs an assignment, much like an equals sign or the assign statement. However, the *define* statement only performs the assignment if the variable is currently undefined. If the variable already has a value, the *define* statement leaves it alone. The *define* statement is especially useful for initializing permanent variables.
- fileglobal -- creates one or more fileglobal variables.
- let -- creates a local variable and assigns a value to it.
- letfileglobal -- creates a fileglobal variable and assigns a value to it.
- letglobal -- creates a global variable and assigns a value to it.
- letpermanent -- creates a permanent variable and assigns a value to it.
- letservervariable -- creates a server variable and assigns a value to it.
- letwindowglobal -- creates a windowglobal variable and assigns a value to it.
- set -- performs an assignment, much like an equals sign or the assign statement. However, the destination of the assignment can be calculated on the fly.
- setfield -- performs an assignment, much like an equals sign or the assign statement. However, the destination field of the assignment can be calculated on the fly.
- setglobal -- sets a value into a global variable. The name of the global variable is calculated on the fly.
- setlocal -- sets a value into a local variable. The name of the local variable is calculated on the fly.
- setlocalsfromdictionary -- converts a dictionary into a collection of local variables. The names and values of the local variables will be derived from the dictionary contents.

History

Version | Status | Notes
10.0 | New | New in this version, but similar to the == operator in Panorama 6.