Selection: CASE · Selección: CASE
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Esta página necesita un navegador reciente (con soporte para SharedArrayBuffer). Por favor, actualiza Chrome, Edge, Firefox o Safari a la última versión.
English
CASE OF picks one branch
- A
CASEruns the branch whose value matches the variable. - Branches are tested in order. The first match runs, and the rest are skipped.
OTHERWISEis the branch for every other value. It comes last.
Español
CASO: selecciona una rama
- Un
CASEejecuta la rama cuyo valor coincida con la variable. - Las ramas se evalúan en orden. Se ejecuta la primera coincidencia y se omiten las demás.
OTHERWISEes la rama para todos los demás valores. Va al final.
English
Español
DECLARE Move : CHAR
Move ← 'W'
CASE OF Move
'W' : OUTPUT "west"
'E' : OUTPUT "east"
OTHERWISE : OUTPUT "other"
ENDCASE
English
Watch out
- A character value uses single quotes:
'W'. - Each branch is one statement here. A longer branch is easier to read as an
IF.
Español
Ten cuidado
- Un valor de carácter utiliza comillas simples:
'W'. - Cada rama es una sola instrucción aquí. Una rama más larga es más fácil de leer como un
IF.
English
Common mistakes
- Close the block with
ENDCASE. - Put a colon after the value, and after
OTHERWISE.
Español
Errores comunes
- Cierra el bloque con
ENDCASE. - Coloca dos puntos después del valor y después de
OTHERWISE.
English
Now you try
- Read a character and choose a word with
CASE OF.
Español
Ahora practica
- Lee un carácter y elige una palabra usando
CASE OF.
Read a CHAR Move. Output west for W, east for E, and other for anything else. · Lee un CHAR Move. Devuelve west para W, east para E, y other para cualquier otra cosa.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.