Skip to content
العربية

1. Printing and strings

To print text and numbers, and to know that اطبع (print) accepts more than one value.

  • A program is a text file with the extension .م that holds instructions. The compiler meem reads 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
اطبع("مرحبا بالعالم")
اطبع("عمري ", 12, " سنة")
Output recorded in the reference handbookmeem برنامج.م · 0.17.1
مرحبا بالعالمعمري 12 سنة

Try this example in the playground

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:

Causes the error
اطبع("العمر " + 30)
Output recorded in the reference handbookmeem برنامج.م · 0.17.1
​[خطأ دلالي E0226] سطر 1:15 - لا يمكن جمع 'نص' و 'عدد64' بـ '+': النوعان مختلفان ولا تحويل تلقائياً   1 | اطبع("العمر " + 30)     |               ^  تلميح: حوّل القيمة صراحةً ليصير الطرفان نصين: "العدد " + نص(5)   أو افصل القيم بفاصلة داخل اطبع: اطبع("العدد ", 5)

Exit code: 2

In the error catalog: E0226

Try this example in the playground

The fix: convert the number to a string, or separate the values with commas inside اطبع:

Fixes it
اطبع("العمر " + نص(30))
اطبع("العمر ", 30)
Output recorded in the reference handbookmeem برنامج.م · 0.17.1
العمر 30العمر 30

Try this example in the playground

Print your name and your age on one line using several values in اطبع, then your age in five years.

Show the solution
Solution
اسم = "سلمى"
عمر = 12
اطبع("اسمي ", اسم, " وعمري ", عمر, " سنة")
اطبع("بعد خمس سنين يصير عمري ", عمر + 5)
Output recorded from the compilermeem 01_حل.م · meem 0.17.3+434e13f
اسمي سلمى وعمري 12 سنةبعد خمس سنين يصير عمري 17

Expressions · The builtin اطبع · Common errors