If there is someplace in the Panorama documentation that says that replace( is a statement, that definitely needs to be corrected. However, I cannot find any text that says that. Certainly the main page for replace( is clear:
It’s always been the case that ANY keyword that ends with ( is a function, not a statement. Functions can be used in formulas, they cannot be used as standalone steps in a procedure. Here is your procedure in Panorama 6 – it doesn’t work there either.
Personally I think the Panorama X error message is better, but it could recognize that the keyword is a function and give an even better error message, I suppose. At least Panorama X correctly identifies the spot of the error, which is a definite improvement.
I think the correct code for what you are trying to do is this, which will work in both Panorama 6 and Panorama X.
«» = replace(«», "Early", "4:30")
«» = replace(«», "Second", "5:45")
«» = replace(«», "Very Late", "8"15")
«» = replace(«», "Late", "7:00")
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 new Panorama X documentation. This page hasn’t been released in the Help wizard yet but it is already available on line:
The relevant section is Statements vs. Functions, which 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
statement.
message "Warning, negative balance"
When used in a program, this statement displays an alert, like this.
But since 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)
But the sqr(
function cannot be used by itself. It’s not an action, so Panorama doesn’t know what to do with this:
sqr(7)
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.