String handling · 字符串处理
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
LENGTH, MID and RIGHT
- The 2026 guide's string routines are
LENGTH,MID,RIGHT,UCASEandLCASE. - Positions start at 1.
MID(text, start, length)copieslengthcharacters fromstart.RIGHT(text, n)copies the lastncharacters.
中文
LENGTH、MID 与 RIGHT
- 2026 指南的字符串例程是
LENGTH、MID、RIGHT、UCASE和LCASE。 - 位置从 1 开始。
MID(text, start, length)从start起复制length个字符。RIGHT(text, n)复制最后n个字符。
OUTPUT LENGTH("Happy Days")
OUTPUT MID("ABCDEFGH", 2, 3)
OUTPUT RIGHT("ABCDEFGH", 3)
English
UCASE and LCASE take one character
- The guide's
UCASEandLCASEtake a single character, not a whole string. UCASE('h')is'H'. A character that is not a letter comes back unchanged.- When a paper needs a whole string in capitals, the insert gives you
TO_UPPER.
中文
UCASE 和 LCASE 接收一个字符
- 指南里的
UCASE和LCASE接收一个字符,不是整串文字。 UCASE('h')是'H'。不是字母的字符会原样返回。- 试卷需要把整串改成大写时,插页会给你
TO_UPPER。
OUTPUT UCASE('h')
OUTPUT LCASE('W')
OUTPUT TO_UPPER("Error 803")
English
& joins strings
&concatenates two strings."Summer" & " " & "Pudding"is"Summer Pudding".- IGCSE 0478 has no
&. There you list values afterOUTPUTwith commas. - Commas still work in this guide when you only want them printed side by side.
中文
& 用来连接字符串
&把两个字符串接在一起。"Summer" & " " & "Pudding"是"Summer Pudding"。- IGCSE 0478 没有
&。那边在OUTPUT后面用逗号列出各个值。 - 这份指南里,只是想把它们印在一起时,逗号仍然可用。
OUTPUT "Summer" & " " & "Pudding"
English
Common mistakes
MIDcounts from 1. The second argument is the start, the third is how many characters.- Do not pass a whole string to
UCASE. That routine is for one character.
中文
常见错误
MID从 1 开始数。第二个参数是起点,第三个是字符个数。- 不要把整串文字传给
UCASE。那个例程只用于一个字符。
English
Now you try
- Use
MID,RIGHTand&.
中文
现在你来试
- 使用
MID、RIGHT和&。
Output · 输出 MID("ABCDEFGH", 2, 3) and RIGHT("ABCDEFGH", 3), each on its own line. · 分别输出 MID("ABCDEFGH", 2, 3) 和 RIGHT("ABCDEFGH", 3),各占一行。
Click Run to see the output here. · 点击“运行”查看此处输出。
Output · 输出 Summer Pudding by joining Summer, a space and Pudding with &. · 用 & 把 Summer、一个空格和 Pudding 接成 Summer Pudding 并输出。
Click Run to see the output here. · 点击“运行”查看此处输出。
Output the upper-case form of the character h, then ERROR 803 using TO_UPPER. · 输出字符 h 的大写形式,再用 TO_UPPER 输出 ERROR 803。
Click Run to see the output here. · 点击“运行”查看此处输出。