setfield
DESTINATION
,
FORMULA

The setfield statement 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.


Parameters

This statement has two parameters:

destination – is a formula that calculates the name of the field that you want to modify.

formula – calculates the value that will be placed into the destination field.


Description

Panorama normally copies data into fields or variables with an assignment. For example, this assignment statement copies the value Westside into the field (or variable) named City.

City="Westside"

Assignment statements work fine as long as it is known where the data needs to be copied into when the program is written. But sometimes this is not known, or it needs to change on the fly. The set statement essentially lets the left hand side of the = change on the fly.

The example procedure below assumes that the current database contains a field for each day of the week: Sunday, Monday, Tuesday, etc. The example copies the variable DepartureTime into the field for the current day.

setfield datepattern( today(),"DayOfWeek"),DepartureTime

Here is the same procedure rewritten without using the set statement (the first line of the code calculates the name of the day).

let dayName = datepattern( today(),"DayOfWeek")
case dayName="Sunday"
     Sunday=DepartureTime
case dayName="Monday"
     Monday=DepartureTime
case dayName="Tuesday"
     Tuesday=DepartureTime
case dayName="Wednesday"
     Wednesday=DepartureTime
case dayName="Thursday"
    Thursday=DepartureTime
case dayName="Friday"
    Friday=DepartureTime
case dayName="Saturday"
    Saturday=DepartureTime
endcase

These two code samples illustrate the power of the set statement, which in this case is doing the same work as 16 statements.


See Also


History

VersionStatusNotes
10.0NewNew in this version.