Selection: CASE · Seleção: CASE
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Esta página precisa de um navegador recente (com suporte a SharedArrayBuffer). Por favor, atualize Chrome, Edge, Firefox ou Safari para a versão mais recente.
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.
Português
CASE OF seleciona um ramo
- Um
CASEexecuta o ramo cujo valor corresponde à variável. - Os ramos são testados em ordem. O primeiro match executa, e os demais são pulados.
OTHERWISEé o ramo para qualquer outro valor. Ele vem por último.
English
Português
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.
Português
Atenção
- Um valor de caractere usa aspas simples:
'W'. - Cada ramo é uma instrução aqui. Um ramo mais longo é mais fácil de ler como um
IF.
English
Common mistakes
- Close the block with
ENDCASE. - Put a colon after the value, and after
OTHERWISE.
Português
Erros comuns
- Feche o bloco com
ENDCASE. - Coloque dois-pontos após o valor, e após
OTHERWISE.
English
Now you try
- Read a character and choose a word with
CASE OF.
Português
Agora você tenta
- Leia um caractere e escolha uma palavra com
CASE OF.
Read a CHAR Move. Output west for W, east for E, and other for anything else. · Leia um inteiro CHAR Move. Imprima west para W, east para E, e other para qualquer outra coisa.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.