NIPO ODIN Version 5.17

Previous Topic

Next Topic

Form Field References

Expressions may refer to fields in a *FORM question using the F operator.

Example of *FORM field references

*Q 10 *FORM *CONTROL Q5 W
At the garden centre, how many items did you buy of each?

1: Flowers: *NUMBER L2 Flower price *NUMBER L2.2
2: Trees: *NUMBER L2 Tree price *NUMBER L2.2
3: Rakes: *NUMBER L2 Rake price *NUMBER L2.2
4: Shovels: *NUMBER L2 Shovel price *NUMBER L2.2

*VARS items
*PUT items [Q10F1+Q10F3+Q10F5+Q10F7]

The references with operator F do not refer to the codes used in the *FORM question, but to the index of the field when searching for fields from the top-left to the bottom-right of the screen in rows. In other words, the field behind "Flowers" is field 1, the field behind "Flower price" is field 2, the field behind "Trees" is field 3 and so forth.

Field numbers do not change even if fields are hidden using the *CONTROL command. For example, field 6 remains field linked with "Rake price" regardless of using *CONTROL.

A reference to a field that does not exist in the *FORM question will always receive to the value of the first field in the question, regardless of whether that field was shown. For example, Q10F10 or Q10F15 would both refer to Q10F1.

Fields can also be referenced to copy values into:

Copying values into fields

*COPY Q10F1 [50]
*COPY Q10F2 [1.25]

Field indexes may be referenced using a variable or an expression. The following is valid syntax to add all price values:

Referencing fields using the repeat number

*VARS totalprice

*put totalprice [0]
*REPEAT 5
*put totalprice [totalprice+Q10F(2*?R)]
*ENDREP

However, variables or expressions may not be used to store values into the fields. The following syntax is invalid:

Invalid field reference syntax

*REPEAT 8
*COPY Q10F(?R) [0]
*ENDREP

See Also