IBM SC34-5764-01 Manual do Utilizador Página 67

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 481
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 66
Exercise - Using a DO UNTIL Loop
Change the program in the previous exercise on page “Exercise - Using a DO WHILE Loop” on page 43
from a DO WHILE to a DO UNTIL loop and achieve the same results. Remember that DO WHILE loops
check for true expressions and DO UNTIL loops check for false expressions, which means their logical
operators are often reversed.
/******************************** REXX ******************************/
/* This program uses a DO UNTIL loop to ask for a password. If the */
/* password is incorrect three times, the loop ends. */
/********************************************************************/
password = 'abracadabra'
time = 0
DO UNTIL (answer = password) | (time = 3)
PULL answer /* Gets ANSWER from input stream */
time = time + 1
END
Figure 24. Example Using DO UNTIL
Control Flow within a Program
Chapter 4. Controlling the Flow within a program 45
Vista de página 66
1 2 ... 62 63 64 65 66 67 68 69 70 71 72 ... 480 481

Comentários a estes Manuais

Sem comentários