Selection: CASE · Sélection : CASE
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Cette page nécessite un navigateur récent (avec support SharedArrayBuffer). Veuillez mettre à jour Chrome, Edge, Firefox ou Safari vers la dernière version.
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.
Français
CASE OF sélectionne une branche
- Un
CASEexécute la branche dont la valeur correspond à la variable. - Les branches sont testées dans l'ordre. La première correspondance s'exécute, les autres sont sautées.
OTHERWISEest la branche pour toute autre valeur. Elle vient en dernier.
English
Français
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.
Français
Attention
- Une valeur de caractère utilise des guillemets simples :
'W'. - Chaque branche est ici une seule instruction. Une branche plus longue est plus lisible sous forme d'
IF.
English
Common mistakes
- Close the block with
ENDCASE. - Put a colon after the value, and after
OTHERWISE.
Français
Erreurs courantes
- Fermez le bloc avec
ENDCASE. - Mettez un deux-points après la valeur, et après
OTHERWISE.
English
Now you try
- Read a character and choose a word with
CASE OF.
Français
À vous maintenant
- Lisez un caractère et choisissez un mot avec
CASE OF.
Read a CHAR Move. Output west for W, east for E, and other for anything else. · Lisez un CHAR Move. Sortez west pour W, east pour E, et other pour tout autre chose.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.