Built-in functions from the insert
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
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.
日本語
リセプトは数字とテキストをつなぐ
- Paper 2には組み込み関数のインサートがあります。擬似コードガイドに含まれないものはここに印刷されており、回答で呼び出すことができます。
LEFT(Text, N)は最初のN文字をコピーします。位置は1から始まります。NUM_TO_STR(87.5)は文字列"87.5"です。行に単語と数字が含まれる場合に&と結合します。
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.
日本語
変換前に確認する
IS_NUM(Text)は文字列が数字である場合にのみTRUEです。"12a"はFALSEです。STR_TO_NUM("23")は数値23なので、1を加えることができます。文字列には加算できません。IS_NUMがテキストが安全であることを示してから変換します。
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).
日本語
ASCとCHR
ASC("A")は整数コード65です。CHR(66)は文字"B"です。"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.
日本語
よくあるミス
UCASEは依然として1文字を受け取ります。大文字の文字列全体はTO_UPPERであり、以前にも触れました。NUM_TO_STRはテキストを返します。STR_TO_NUMは数値を返します。互いに交換不可です。
English
Now you try
- Use
LEFT, then a joined number, thenIS_NUMbefore a conversion.
日本語
あなたも試してみよう
- 変換の前に、
LEFTを使い、結合された数値、そしてIS_NUMを配置します。
Output LEFT("Computer", 3).
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。
Output Score: 87.5 on one line by joining the word and NUM_TO_STR(87.5) with &.
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。
Text is "23". If IS_NUM(Text), output STR_TO_NUM(Text) + 1. Otherwise output bad.
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。