Object

The obj type is used to store values of the following types - int, bool, float, str, arr.obj, map.obj. If no value is assigned to the object, then it is equal to nil. An object can be assigned values of a type that is different from the current one. The operators and functions for working with objects are described here.

Operators

Operator

Result

Description

*obj

int

If the object is arr.obj or map.obj, the number of items in the array is returned. Otherwise, it returns 0.

obj ?

bool

Calls bool(obj).

obj = arr.typename

obj

Assigning an array to an object.

obj = bool

obj

Assigning a boolean value to an object.

obj = float

obj

Assigning a decimal number to an object.

obj = int

obj

Assigning a number to an object.

obj = map.typename

obj

Assigning an associative array to an object.

obj = obj

obj

Assignment operator.

obj = str

obj

Assigning a string to an object.

obj &= obj

obj

Creates a clone of the object. The new variable will work with the same data set.

obj [ int/str ]

obj

Assign / get the value of an array by index. If the object is not arr.obj or map.obj, then an error occurs.

Functions

bool(obj o) bool

The bool function returns a logical value of the current type. For example, if an object contains a string, the result of calling bool(str) is returned. If the object is not defined, an error is returned.

bool(obj o, bool def) bool

The bool function returns a logical value of the current type. If the object is not defined, the second parameter is returned.

float(obj o) float

The float function converts an object to a decimal floating-point number. The object must contain a value of str, int, float type, otherwise, an error occurs.

float(obj o, float def) float

The float function converts an object to a decimal floating-point number. If the object is not defined, the second parameter is returned.

int(obj o) int

The int function converts an object to an integer. The object must contain a value of str, int, float, bool type, otherwise, an error occurs.

int(obj o, int def) int

The int function converts an object to an integer. If the object is not defined, the second parameter is returned.

IsNil(obj o) bool

The IsNil function returns true if the object is undefined (equal to nil). Otherwise, the function returns false.

item(obj o, int i) obj

The item function returns the i-th element of the object. The object must be of arr.obj type. If the element is missing, then an empty object is returned.

item(obj o, str s) obj

The item function returns the value of key s. The object must be of map.obj type. If there is no element, it returns an empty object.

obj(arr.typename a) obj

The obj function converts an array of the arr type into an object.

obj(bool b) obj

The obj function creates an object with the specified logical value.

obj(float f) obj

The obj function creates an object with the specified float value.

obj(int i) obj

The obj function creates an object with the specified int value.

obj(map.typename m) obj

The obj function converts an associative array of the map type into an object.

obj(str s) obj

The obj function creates an object with the specified str value.

str(obj o) str

The str function converts the object to a string and returns it.

str(obj o, str def) str

The str function converts the object to a string and returns it. If the object is not defined, the second parameter is returned.

Type(obj o) str

The Type function returns the value type of the specified object. The following types may be returned: int, bool, float, str, arr.obj, map.obj. If the object is undefined, then nil is returned.