Field References

Home Scripting Field References

You refer to a field/control, or more exactly, its current value, by specifying its name.

If you just give a field reference like the following

field "Amount"

it refers to the field Amount on the current card. If you want to access the value of a field on a specific card, add a card reference after it:

field "Amount" of card "Bill #10"

Like with card references, you can "calculate" which field you want to access, by giving a simple expression instead of a constant string, e.g. with the string variable amountField containing the string "Amount":

field amountField

Use parenthesis in non-simple cases:

field (amountField & "1")

(You find some more details about this potential pitfall in chapter Expressions.)

The result of the evaluation of a field reference is a value that has the type of the field: From a text field you get a text/string value, from an integer field an integer value, etc.

With the implementation of the script language not yet completed, for some types referencing a field value is the only way to get a value of that type. E.g. the script language does not yet know date constants; if you want a date, you have to take it from a date field.


If you are familiar with programming, especially object-oriented programming, it might seem confusing to you that an expression like field "Amount" refers to the value of the field and not to the field itself as an object. Maybe you would expect something like value of field "Amount" to refer to the value.

But on the one hand, MoStacks just follows HyperTalk here, using a simple notation, and on the other hand there are very few occasions where you would want to do something with the field itself as an object, so you would end up repeating value of again and again gaining essentially nothing. Anyway, with the current status of implementation, you can't do anything at all with the field itself in a MoStacks script.