1. Printing and strings
To print text and numbers, and to know that اطبع (print) accepts more than one value.
Explanation
Section titled “Explanation”- A program is a text file with the extension
.مthat holds instructions. The compilermeemreads it and runs it (glossary). اطبع(...)writes what is between the parentheses to the screen, then moves to a new line.- A string is text between double quotes:
"مرحبا". اطبعaccepts several values separated by commas, and prints them next to each other with no space. If you want a space between the values, write it yourself inside the string.
Example
Section titled “Example”اطبع("مرحبا بالعالم")اطبع("عمري ", 12, " سنة")Common mistakes
Section titled “Common mistakes”Two common mistakes: a string without quotes, and + between a string and a number. The + sign joins a string to a string only; a string with a number is an error the compiler catches before the program runs:
اطبع("العمر " + 30)Exit code: 2
In the error catalog: E0226
The fix: convert the number to a string, or separate the values with commas inside اطبع:
اطبع("العمر " + نص(30))اطبع("العمر ", 30)Exercise
Section titled “Exercise”Print your name and your age on one line using several values in اطبع, then your age in five years.
Show the solution
اسم = "سلمى"عمر = 12اطبع("اسمي ", اسم, " وعمري ", عمر, " سنة")اطبع("بعد خمس سنين يصير عمري ", عمر + 5)See also
Section titled “See also”Expressions · The builtin اطبع · Common errors