NIPO ODIN Version 5.17
*GOSUB
Purpose
Jumps to a subroutine.
Syntax
*GOSUB <name>
Description
Takes care of a jump to a subroutine specified by name. After return from the subroutine the interview will continue with the next command following *GOSUB . This command is also allowed under condition.
Arguments
name The name of the subroutine that is called. This subroutine has to be defined earlier in the questionnaire.
Remark
If you're working with so-called 'floating' data fields you don't have to specify the *FIELD command. When fixing the answer fields of the questionnaire it will be put there automatically.
Example 1
*TEXTVARS BRAND
*SUBROUTINE OPINION *QUESTION 901 *CODES 1 What do you think of the service of *? BRAND?
1: Very good 2: Good 3: Poor 4: Very poor
5: Don’t know \ no answer
*ENDSUB
*QUESTION 1 *CODES 61L5 *MULTI *SAVE BRAND Which of the following gas stations have you ever visited?
1: Esso *GOSUB OPINION *FIELD 66L1 2: Shell *GOSUB OPINION *FIELD 67L1 3: Texaco *GOSUB OPINION *FIELD 68L1 4: BP *GOSUB OPINION *FIELD 69L1 5: Mobil *GOSUB OPINION *FIELD 70L1
In this example, for each answer mentioned, the subroutine is called - in reverse order that they were entered in Q1. Data positions are fixed, each subroutine call requires only 1 position, specified in the *FIELD command. Question 901 is set to position 1 in the field, a relative position within specified field.
Example 2
*TEXTVARS BRAND
*SUBROUTINE OPINION *QUESTION 1 *CODES L1 What do you think of the service of *? BRAND?
1: Very good 2: Good 3: Poor 4: Very poor
5: Don’t know \ no answer
*ENDSUB
*QUESTION 2 *CODES L5 *MULTI Which of the following gas stations have you ever visited?
1: Esso 2: Shell 3: Texaco 4: BP 5: Mobil
*IF [ Q2, 2 ] *PUT BRAND "Shell" *GOSUB OPINION *IF [ Q2, 3 ] *PUT BRAND "Texaco" *GOSUB OPINION
In this example, if answer 2 or 3 would be selected, the text of the answer is stored in a variable and the subroutine is called. Data positions are not fixed, so the *FIELD command is not specified here.
|