NIPO ODIN Version 5.17

*SUBROUTINE ... *ENDSUB

Purpose

Defines a subroutine.

Syntax

*SUBROUTINE name
<commands>
*ENDSUB

Description

Defines the start of a subroutine. This command has to be at the beginning of a line. This command is always used in combination with *ENDSUB (end subroutine). The subroutine can be jumped to at any time.

A subroutine consists of a set of commands and questions that the system considers as a special component. When a subroutine is called in the questionnaire the system executes the commands in the subroutine. It is as if the commands in the subroutine are inserted where the subroutine was called. The answer fields in a subroutine will be considered relative.

When a subroutine is called the system uses the position in the *FIELD parameter belonging to *GOSUB as the starting point to determine where the answers have to be put. A subroutine is considered a separate component of the questionnaire. It should be placed somewhere in the questionnaire before the first call to the subroutine.

In a subroutine you can call subroutines recursively with a maximum depth limited by the computer memory and the 99999 data positions available for NIPO ODIN.

Subroutines can also be called after a *NEW command, when placed in the first sub-questionnaires.

Arguments

name
The name of the subroutine.

Remarks

It is not allowed to jump out of a subroutine by means of the *GOTO command. To end subroutine execution, use *RETURN instead. At least one *RETURN must be defined.

Example

*TEXTVARS BRAND

*SUBROUTINE OPINION
*QUESTION 1 *CODES 1
What do you think of the service of *? BRAND?

1: Very good
2: Good
3: Poor
4: Very poor

*ENDSUB

*QUESTION 2 *CODES 61L5 *MULTI *SAVE BRAND
Which of the following gas stations have you ever visited?

1: Esso *GOSUB OPINION
2: Shell *GOSUB OPINION
3: Texaco *GOSUB OPINION
4: BP *GOSUB OPINION
5: Mobil *GOSUB OPINION

See Also