The question of statements vs. functions, and where they can be used, has tripped up more than one Panorama user over the years. I’ve taken another crack at explaining this in the Code page of the Panorama X documentation.
The relevant section is Statements vs. Functions, which for convenience I have included below. Please note that everything stated in this section is applicable to both Panorama 6 and Panorama X.
Statements vs. Functions
In some programming languages, all actions are functions that can return a value and be used in formulas. In Panorama, however, statements and functions are distinct. In Panorama, a statement performs an action. A function, on the other hand, returns a value. You can’t use a function where Panorama is expecting a statement, and you can’t use a statement in a formula, where Panorama needs a value.
To illustrate this, consider the
message "Warning, negative balance"
When used in a program, this statement displays an alert, like this.
message is a statement, not a function, it doesn’t return a value and you cannot use it in a formula. So this code will not work:
x = message "Warning, negative balance"
and neither will this:
x = message("Warning, negative balance")
On the other hand, consider the
sqr( function, which calculates a square root. Since this is a function and returns a value, it’s perfectly fine to use it in a formula, for example with this assignment.
x = sqr(7)
sqr( function cannot be used by itself. It’s not an action, so Panorama doesn’t know what to do with this:
The basic rule is, if a keyword ends with a (, it’s a function and returns a value, and can be used in formulas. If a keyword doesn’t end with a (, it’s a statement and it performs an action.