Language basics




Note : WorldLang's configurable keywords and built-in function names provide users with flexibility, allowing them to tailor the language to their specific needs while maintaining its core principles. Additionally, as a multilingual programming language, WorldLang offers users the option to switch between different languages according to their preferences. Although Arabic is the default language, users can easily select their preferred language, ensuring a personalized and comfortable programming experience. This versatility empowers users to code in a language that resonates with them, enhancing their overall programming journey.




Outputs :



Syntax :

function_name( "parameter" )

Example :

طباعة( "أهلا بالعالم" )
Terminal Output



Variables :



Syntax :

var/<keyword name> variablename = <value>

Dynamic typing :

متغير س = "أهلا بالعالم"
متغير ص = 100

Example :

متغير س = 10
متغير ص = 5
طباعة(س + ص)
Terminal Output



User input :



Syntax :

function_name("prompt_message")

Example : text input

متغير الاسم = استقبل("أدخل اسمك : ")
طباعة(الاسم)
Terminal Output

Example : number input

متغير الرقم_الأول = استقبل_رقم("أدخل الرقم الأول: ")
متغير الرقم_الثاني = استقبل_رقم("أدخل الرقم الثاني: ")
طباعة(الرقم_الأول + الرقم_الثاني)
Terminal Output



Conditions :



Syntax : inline conditions

if condition do something

Example : inline conditions

اذا 5 < 10 نفذ طباعة("5 اصغر من 10")
Terminal Output

Syntax : multiline conditions

if condition do 
  something
elif condition do
  something
else 
  something
end 
                

Example : multiline conditions

اذا 5 < 10 نفذ 
  طباعة("5 اصغر من 10")
أما_اذا 5 > 10 نفذ
  طباعة("5 اكبر من 10")
والا 
  طباعة("5 تساوي 10")
نهاية 
                
Terminal Output



Loops :



Syntax : inline for loops

for name = value1 to value2 do something

Example : inline for loops

من ا = 0 الي 10 نفذ طباعة("أهلا بالعالم")
Terminal Output

Syntax : multiline for loops

for name = value1 to value2 do 
  something
  if condition do
    break/continue
  else 
    break/continue
  end
end
                

Example : multiline for loops

من ا =  0 الي 10 نفذ 
  طباعة (ا)
  اذا ا == 5 نفذ
    توقف 
  نهاية 
نهاية 
                
Terminal Output

Example : looping on a list

متغير ق =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
من ا = 0 الي حجم(ق) نفذ طباعة(ق/ا)
                
Terminal Output



Dictionaries / Hash Tables :



Syntax :

var dict_name = { "key1" : "value1" , "key2" : "value2" }

Example : accessing dictionary values

متغير معلومات = {"الاسم": "زياد", "العمر": 20}
طباعة(معلومات/"الاسم")
                
Terminal Output



While loops :


Syntax : inline while loops

while condition do something

Example : inline while loops

بينما صحيح نفذ طباعة("أهلا بالعالم")
Terminal Output

Syntax : multiline while loops

while condition do 
  something
end 
                

Example : multiline while loops

متغير ب = 0 
بينما  ب < 10 نفذ
  طباعة("ب اصغر من 10")
  متغير ب = ب + 1 
نهاية 
                
Terminal Output



Functions :



Syntax : inline functions

func function_name(parameters) -> output

Example : inline functions

دالة أضف_واحد(س) -> س + 1
Terminal Output

Syntax : multiline functions

func function_name(parameters) 
  return something
end 
                

Example : multiline functions

دالة اضف_واحد(س) 
  ارجاع س + 1
نهاية 
                
Terminal Output



Import Modules :



Syntax :

Import/(Keyword_name) (module_name)

Example:

استدعاء ( "math.world" )
Terminal Output



Built-in Modules :



Syntax :

import("module_name")

Example (English) :

import("Random")
print(gen_random(1, 10))

Example (Arabic) :

استدعاء("Random")
طباعة(توليد_رقم_عشوائي(1, 10))
Terminal Output



Read files :



Syntax :

function_name( "filename.ext" )

Example :

متغير س = قراءة_ملف( "test.txt" )
Terminal Output



Write files :



Syntax :

function_name( "filename.ext" , "content" )

Example :

كتابة_ملف( "text.txt" , "Hello world" )
Terminal Output



Advanced Example: Hardware Voice Controller



This example combines built-in modules (Serial & Speech), dictionaries, and infinite loops to listen for voice inputs and stream commands to a microcontroller driving a vehicle:


استدعاء("Serial") ; استدعاء("Speech")
متغير التعليمات = {"انعطف يمينا": "turn right", "انعطف يسارا": "turn left", "تحرك للامام": "move forward", "تحرك للخلف": "move backwards"}
بينما صحيح نفذ
	متغير التعليمة = استمع("ar")
	ارسال("COM4", 9600, التعليمات/التعليمة)
نهاية
                
Terminal Output



⬅ Prev
Next ➡