String handling
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
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.
OUTPUT LENGTH("Happy Days")
OUTPUT MID("ABCDEFGH", 2, 3)
OUTPUT RIGHT("ABCDEFGH", 3)
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.
OUTPUT UCASE('h')
OUTPUT LCASE('W')
OUTPUT TO_UPPER("Error 803")
& 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.
OUTPUT "Summer" & " " & "Pudding"
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.
Now you try
- Use
MID,RIGHTand&.
Output MID("ABCDEFGH", 2, 3) and RIGHT("ABCDEFGH", 3), each on its own line.
Click Run to see the output here.
Output Summer Pudding by joining Summer, a space and Pudding with &.
Click Run to see the output here.
Output the upper-case form of the character h, then ERROR 803 using TO_UPPER.
Click Run to see the output here.