Skip to main content

Data Types

Learn about the types of data can be assigned to references and used elsewhere.

Variables and constants in ABJAD can have one of four main types.

  1. مقطع: text or string
  2. رقم: number, including all the natural and decimal numbers
  3. منطق: boolean
  4. User-defined type

String

A string value must be enclosed by two double quotations. e.g. "!مرحبا بالعالم"

note

A string value cannot span on more than one line.

Number

A number value includes natural and decimal values between ±5.0 × 10−324 and ±1.7 × 10308 e.g. 12.3

Boolean

A boolean value can have one of two values صحيح (true) or خطأ (false)

User-Defined Types

Discussed Later in classes.

Get the Type of a Value

You can get the type of the value using the نوع keyword followed by parentheses enclosing the value itself.

e.g. This code will print رقم

ثابت رقم باي = 3.14؛
أكتب(نوع(باي))؛

Conversions

Conversion is allowed between some of the types under some conditions.

Number to String

Conversion is possible from Number data type to String data type by calling on the function مقطع and passing a number.

e.g. عشرة will have the value of "10".

متغير مقطع عشرة = مقطع(10)؛

String to Number

Converting a String data type to Number data type happens by calling on the function رقم and passing it a string representation of a number. e.g. خمسة will have the value of 5.

متغير رقم خمسة = رقم("5")؛
danger

The following example will throw an error since the value is not qualified to be a number

متغير رقم عدد_غير_صالح = رقم("5.3.6")؛

Boolean to String

Converting a Boolean to String happens by calling on the function مقطع and passing it a boolean e.g. جواب will have the value of "صحيح".

متغير مقطع جواب = مقطع(صحيح)؛

String to Boolean

Converting a String to Boolean happens by calling on the function منطق and passing it a string representation of a boolean value.

e.g. جواب will have the value of خطأ.

متغير منطق جواب = منطق("خطأ")؛
danger

The following example will throw an error since the value is not qualified to be a boolean

متغير منطق جواب_غير_صالح = منطق("صح")؛