Scripts in an object can return values just like the scripts you’ve written in a workspace. There is one difference: Unlike a blocks and scripts in a workspace, you must use a return statement to return a value. Scripts do not return the value of the last expression unless you write the work return before it.
As an example, consider the following script for the message discount:
$ on amount.
$ percent.
percent := 0.
if (amount >= 10.00) then [ percent := 0.025 ].
if (amount >= 25.00) then [ percent := 0.05 ].
if (amount >= 100.00) then [ percent := 0.075 ].
return amount * percent.
(Add the property discount to cash-register with this as its script, we’ll need it later).
The last line of this script has to have the word return. If it did not, then this script, when executed due to the message discount sent to cash-register, would not return any value at all.