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.

The cmpobjtype function type is used to compare two objects. Functions of this type are used to sort objects in an array.

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
Adding an object to an array of objects.
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.

The arr function returns an array of objects. Object o must be an array, otherwise it returns an error. Calling the function does not create a new array, but returns the current array that contains the o object.

The arrstr function converts an array of objects into an array of strings. The o object must be an array, otherwise an error is returned. The function returns the resulting array of strings.

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.

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

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.

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

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.

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

The IsArray function returns true if the object is an array. Otherwise, the function returns false.

The IsMap function returns true if the object is an associative array (map). Otherwise, the function returns false.

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

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.

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.

The map function returns an associative array of objects. The o object must be an associative array (map), otherwise an error is returned. When the function is called, no new array is created, but the current map which contains object o is returned.

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

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

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

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

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

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

The Sort function sorts an array of objects and returns it. Sorting is done using a function of cmpobjfunc type.
func mySort(obj left, obj right) int {
if str(left) < str(right) : return -1
if str(left) > str(right) : return 1
return 0
}
run str {
arr a = {"qwr","7","10","ab","тест","абв", "ka"}
obj o = a
Sort( arr(o), &mySort.cmpobjfunc )
...
}

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

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

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.
Last modified 1yr ago
Copy link
On this page
Types
fn cmpobjfunc(obj, obj) int
Operators
Functions
arr(obj o) arr.obj
arrstr(obj o) arr.str
bool(obj o) bool
bool(obj o, bool def) bool
float(obj o) float
float(obj o, float def) float
int(obj o) int
int(obj o, int def) int
IsArray(obj o) bool
IsMap(obj o) bool
IsNil(obj o) bool
item(obj o, int i) obj
item(obj o, str s) obj
map(obj o) map.obj
obj(arr.typename a) obj
obj(bool b) obj
obj(float f) obj
obj(int i) obj
obj(map.typename m) obj
obj(str s) obj
Sort(arr.obj o, cmpobjfunc cmpfunc) arr.obj
str(obj o) str
str(obj o, str def) str
Type(obj o) str