NIPO ODIN Version 5.17

*REPEAT ... *ENDREP

Purpose

Start repetition block.

Syntax

*REPEAT n

<commands>

*ENDREP

Description

Defines the start of a repetition block. This command has to be on the beginning of a line. This command is always used in combination with *ENDREP (end repetition block). A repetition block consists of a set of commands and questions that are considered to be a special component. When a repetition block is executed in the questionnaire, the system executes all commands within the repetition block as many times as is indicated by n. The answer fields within the repetition block are considered relative positions to the data field. When a repetition block is executed, the system uses the starting position defined by *FIELD on the *REPEAT statement as the starting point to determine where the answers have to be stored. For every repetition the answer fields belonging to the commands in the repetition block are stored in fixed fields one after another. It is possible to refer to the repetition number with the ?R operator or the *REPNUM command.

Arguments

n
This is a positive integer that gives the number of repetitions.

Remarks

  • You cannot jump out of a repetition block with the *GOTO command. To terminate a repetition block, the *END command must be used.
  • Jumping from outside the repetition block into a question within a repetition block with the *GOTO command is not possible.
  • The repeat numbers in repeat blocks can be controlled by *CONTROL, randomized by *RANDOM, inverted by *INV and rotated by *ROT.

Example 1

*TEXTVARS who
*REPEAT 5 *FIELD 86L10
*REPNUM 1: *PUT who "Johnny"
*REPNUM 2: *PUT who "Mary"
*REPNUM 3: *PUT who "Bill"
*REPNUM 4: *PUT who "Anne"
*REPNUM 5: *PUT who "Joey"

*QUESTION 1 *NUMBER 1L2
How old is *? who?

*ENDREP

In this example, question 1 is repeated 5 times. The answers of the 5 questions are stored in the data field 86L10 (for each answer 2 positions = 1L2 x 5 questions). For example, the answers for Johnny are stored in position 86L2, for Mary in 88L2, et cetera.

Example 2

*TEXTVARS who
*REPEAT 5 *FIELD 86L15 *RANDOM 1L1
*REPNUM 1: *PUT who "Johnny"
*REPNUM 2: *PUT who "Mary"
*REPNUM 3: *PUT who "Bill"
*REPNUM 4: *PUT who "Anne"
*REPNUM 5: *PUT who "Joey"

*QUESTION 1 *NUMBER 2L2
How old is *? who?

*ENDREP

In this example, question 1 is repeated 5 times, in random order. The answers of the 5 questions are stored in the data field 86L10 (for each answer 2 positions = 1L2 x 5 questions). For example, the answers for Johnny are stored in position 86L2, for Mary in 88L2, et cetera.

Example 3

*TEXTVARS paper
*QUESTION 2 *CODES 61L7 *MULTI
Which of the following newspapers do you know?

1: La Repubblica
2: La Stanza
3: The Mirror
4: The New York Times
5: Le Figaro
6: La Libération
7: None *NMUL

*REPEAT 6 *FIELD 68L6
*PUT paper Q2,?R

*QUESTION 3 *CODES 1 *IF [Q2,?R]
How often do you read *?paper?

1: Daily
2: Once a week
3: Once a month
4: Don’t know

*ENDREP

In this example, question 3 is repeated 6 times. Only for those newspapers mentioned in Q2 the question is displayed.

Example 4

*TEXTVARS paper
*QUESTION 2 *CODES 61L7 *MULTI
Which of the following newspapers do you know?

1: La Repubblica
2: La Stanza
3: The Mirror
4: The New York Times
5: Le Figaro
6: La Libération
7: None *NMUL

*REPEAT 6 *FIELD 68L6 *CONTROL Q2 W
*PUT paper Q2,?R

*QUESTION 3 *CODES 1
How often do you read *?paper?

1: Daily
2: Once a week
3: Once a month
4: Don’t know

*ENDREP

This example is the same as the previous, but now the *IF statement has been replaced with a *CONTROL statement to the same effect.

See Also