home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / ibm1 / do101j2.arj / REPEAT.SCR < prev    next >
Text File  |  1991-12-03  |  2KB  |  66 lines

  1. .pg wi full clr cy
  2.     COMMAND NAME»gray«: »%t« RepeatLoop »ye«
  3.  
  4.     /REPEAT
  5.     /UNTIL {value1} [EQ/LT/GT/NE/GE/LE/LK] {value}[ [{else label}][ ASIS]]»gray«
  6. /DRAW H 5 1 78
  7. .wi 1 6 79 25 #
  8.     »wh«The »%t«/REPEAT»wh« and »%t«/UNTIL»wh« commands must be used in a pair. The
  9.     section of the script between these commands is repeated
  10.     until the condition on the »%t«/UNTIL»#« statement is true. Then
  11.     the script continues with the next command after the »%t«/UNTIL»#«.
  12.  
  13.     The »%t«/UNTIL»#« command is evaluated the same as the Compare
  14.     (»%t«/IF»#«) command.
  15.  
  16.     »%t«/REPEAT»#« loops can be nested up to »ye«10»#« deep.
  17. .pg clr
  18.     Let's look at a couple of nested loops just to see how things
  19.     work. We'll use Counter's 1 and 2 to control the »%t«/REPEAT»#«
  20.     execution. Here are the loops we'll use:
  21. »wh«
  22.     /MATH Counter1 0
  23.     »%t«/REPEAT»cy«  -----------------+
  24.     »wh«/MATH Counter2 2»cy«          |
  25.     »%t«/REPEAT»cy«  ---------------+ |
  26.     »wh«/DEC Counter2»cy«           | |
  27.     »%t«/UNTIL»wh« %%Counter2 EQ 0»cy«  <+ |
  28.     »wh«/INC Counter1 0.5»cy«         |
  29.     »%t«/UNTIL»wh« %%Counter1 EQ 2»cy«  <--+
  30. .pg 25 wi 40 11 79 25 gr
  31. Now let's watch the execution
  32. at the bottom of the screen»gray«:»#«
  33. /SET C1 ye
  34. |/MATH Counter1 0
  35. |/REPEAT  This loop repeats until counter 1 eq 2
  36. |/MATH Counter2 2
  37. /SET C2 ye
  38. .go 1 4
  39. »cy«Counter 1»gray«: »%c1«%Counter1(##.#)»#«
  40. .go 1 5
  41. »cy«Counter 2»gray«: »%c2«%Counter2(##.#)»#«
  42. |/REPEAT  This loop repeats until counter 2 eq 0
  43. |/DEC Counter2
  44. /if  %Counter2 EQ 0 Reset2
  45. /SET C2 +re
  46. /GOTO Cont2
  47. :Reset2
  48. /SET C2 ye
  49. :Cont2
  50. .go 1 5
  51. »cy«Counter 2»gray«: »%c2«%Counter2(##.#)»#«
  52. |/UNTIL %Counter2 EQ 0
  53. |/INC Counter1 0.5
  54. /if  %Counter1 EQ 2 Cont1
  55. /SET C1 +re
  56. :cont1
  57. .go 1 4
  58. »cy«Counter 1»gray«: »%c1«%Counter1(##.#)»#«
  59. |/UNTIL %Counter1 EQ 2
  60. .go 1 7
  61. Since both »%t«/UNTIL»#« statements have
  62. been satisfied, the »%t«/REPEAT»#« loops
  63. terminate.
  64.  
  65. /ENDEXEC CLEAR
  66.