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 มีเอกสารแนบที่มี built-in functions สิ่งที่ไม่ได้ระบุในคู่มือ pseudocode จะพิมพ์ออกที่นั่น และคำตอบอาจเรียกใช้มันได้
LEFT(Text, N)คัดลอกNตัวอักษรแรก ตำแหน่งเริ่มนับจาก 1 เสมอNUM_TO_STR(87.5)คือ string"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ก็ต่อเมื่อ string นั้นเป็นตัวเลข"12a"จะมีค่าเป็นFALSESTR_TO_NUM("23")คือเลข23ดังนั้นคุณสามารถบวก 1 ได้ string ไม่สามารถบวกได้- แปลงชนิดข้อมูลก็ต่อเมื่อ
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")คือรหัสจำนวนเต็ม65CHR(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ยังต้องการอักขระหนึ่งตัว String ทั้งหมดเป็นตัวพิมพ์ใหญ่จะเป็นTO_UPPERซึ่งคุณเคยเห็นมาก่อนNUM_TO_STRคืนค่าเป็นข้อความSTR_TO_NUMคืนค่าเป็นตัวเลข They are not interchangeable
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. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
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. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
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. · คลิก Run เพื่อดูผลลัพธ์ที่นี่