next up previous contents index
Next: Conditional statements Up: Looping with a control Previous: Looping with a control

General remarks

  1. To access the current value of the control variable whose name is N1, use the syntax `[N1]' as appropriate. (See the section on line parsing). The example just given illustrates this.
  2. From the point of view of accessing the value of a control variable, if two or more control variables with the same name are active, then the most recently defined is used. Consequently, the action of the following (legal) sequence:

    BD>for : i=1,1,2, i=4,5,9 tex2html_wrap_inline33712

    BD>print : [i] tex2html_wrap_inline33712

    BD>end : tex2html_wrap_inline33712

    would be to print out the values 4 and 9 twice.

    Furthermore, the names of control variables used for FOR:  loops take precedence over strings with the same name.

  3. For interactive work, when you issue a standard FOR:  command, the program simply copies your further inputs (without obeying any commands) until you input an END:  command to mark the end of the loop. Thereafter the loop is processed in the usual way. The interactive FOR: -END:  construction causes the copying of command lines to a temporary file. Every line is copied as an original, without any parsing: errors in the command syntax may be reported, but the process will continue. During such interactive work, the following prompt  is used:

    BD/ tex2html_wrap_inline33712

    to indicate to you that the program is awaiting an END:  statement before processing your inputs.

  4. There are no limits to the number of active FOR:  loops, subject to memory limitations.
  5. The number of control variables that can be defined in one FOR:  statement is limited to 30.
  6. All commands are permitted during the processing of a standard for-end loop. However, certain commands are disallowed during processing of a one-line FOR:  statement. These include

    1. channel switching via M: , GOTO: , and RETURN:  commands;
    2. if-then-else constructions via IF: , ELSE: , and ENDIF:  commands;
    3. other looping via FOR: , END: , REPEAT: , UNTIL: , WHILE: , and WEND:  commands;
    4. channel closing via the REFRESH:  command.

  7. The names and details of all active FOR:  statements can be checked by issuing a LOOK:  command with the for  argument. Control variables defined in the same FOR:  statement are marked ``not final'' except for the first.

       


next up previous contents index
Next: Conditional statements Up: Looping with a control Previous: Looping with a control

David Wooff
Wed Oct 21 15:14:31 BST 1998