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.
עברית
קבלה מחברת מספר עם טקסט
- לכל ניסוי 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⟩ עדיין לוקח אות אחת. מחרוזת שלמה באותיות גדולות היא ⟨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). · הדפס את 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 &. · הדפס את Score: 87.5 בשורה אחת על ידי חיבור המילה וNUM_TO_STR(87.5) באמצעות &.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Text is "23". If IS_NUM(Text), output STR_TO_NUM(Text) + 1. Otherwise output bad. · Text הוא "23". אם IS_NUM(Text), הדפס STR_TO_NUM(Text) + 1. אחרת הדפס bad.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.