Built-in functions from the insert · Funções embutidas do insert
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
A receipt joins a number to text
- Every Paper 2 has an insert of built-in functions. Anything not in the pseudocode guide is printed there, and an answer may call it.
LEFT(Text, N)copies the firstNcharacters. Positions still start at 1.NUM_TO_STR(87.5)is the string"87.5". Join it with&when the line must contain words and a number.
Português
Um recibo junta um número a um texto
- Todo Paper 2 tem um anexo de funções embutidas. Tudo o que não está no guia de pseudocódigo é impresso lá, e uma resposta pode chamá-la.
LEFT(Text, N)copia os primeirosNcaracteres. As posições ainda começam em 1.NUM_TO_STR(87.5)é a string"87.5". Junte-a com&quando a linha deve conter palavras e um número.
OUTPUT LEFT("Computer", 3)
OUTPUT "Score: " & NUM_TO_STR(87.5)
English
Check before you convert
IS_NUM(Text)isTRUEonly when the string is a number."12a"isFALSE.STR_TO_NUM("23")is the number23, so you can add 1 to it. A string cannot be added.- Convert only after
IS_NUMsays the text is safe.
Português
Verifique antes de converter
IS_NUM(Text)éTRUEapenas quando a string é um número."12a"éFALSE.STR_TO_NUM("23")é o número23, então você pode somar 1 a ele. Uma string não pode ser somada.- Converta apenas depois que
IS_NUMdisser que o texto está seguro.
DECLARE Text : STRING
Text ← "23"
IF IS_NUM(Text) THEN
OUTPUT STR_TO_NUM(Text) + 1
ELSE
OUTPUT "bad"
ENDIF
English
ASC and CHR
ASC("A")is the integer code65.CHR(66)is the character"B".- The next letter after
"A"isCHR(ASC("A") + 1).
Português
ASC e CHR
ASC("A")é o código inteiro65.CHR(66)é o caractere"B".- A próxima letra após
"A"éCHR(ASC("A") + 1).
OUTPUT CHR(ASC("A") + 1)
OUTPUT IS_NUM("12a")
English
Common mistakes
UCASEstill takes one character. A whole string in capitals isTO_UPPER, which you met earlier.NUM_TO_STRreturns text.STR_TO_NUMreturns a number. They are not interchangeable.
Português
Erros comuns
UCASEainda aceita um único caractere. Uma string inteira em maiúsculas éTO_UPPER, que você viu anteriormente.NUM_TO_STRretorna texto.STR_TO_NUMretorna um número. Eles não são intercambiáveis.
English
Now you try
- Use
LEFT, then a joined number, thenIS_NUMbefore a conversion.
Português
Agora você tenta
- Use
LEFT, depois um número concatenado, entãoIS_NUMantes de uma conversão.
Output · Saída LEFT("Computer", 3). · Imprima LEFT("Computer", 3).
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
Output · Saída Score: 87.5 on one line by joining the word and NUM_TO_STR(87.5) with &. · Imprima Score: 87.5 em uma linha unindo a palavra e NUM_TO_STR(87.5) com &.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
Text is "23". If IS_NUM(Text), output STR_TO_NUM(Text) + 1. Otherwise output bad. · Text é "23". Se IS_NUM(Text), imprima STR_TO_NUM(Text) + 1. Caso contrário imprima bad.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.