Context
There are no global variables in the Gentee language. One of the ways to exchange data is a special associative array of strings (context). Any function can safely add key-value pairs there or get a value by key. In addition, the context has the ability to substitute other existing values from the context. For example, if the pairs "a": "String A" and "b": "String B" has been defined, then "#a# and #b#" will return "String A and String B". The functions and operators for working with the context are described below.
Operators
Operator | Result | Description |
# ident | str | The same as CtxGet(key), where ident is the context key. |
## str | str | The same as Ctx(str). Specify any expression that returns a string. |
ident #= str | str | The same as CtxSet(str key, str s), where ident is the context key. |
ident #= bool | str | The same as CtxSet(str key, bool b), where ident is the context key. |
ident #= float | str | The same as CtxSet(str key, float f), where ident is the context key. |
ident #= int | str | The same as CtxSet(str key, int i), where ident is the context key. |
Functions
Ctx(str input) str
The Ctx function replaces substrings #keyname# in input string with the value of the corresponding key, if it exists.
CtxGet(str key) str
The CtxGet function gets the value of the key key, replaces all occurrences of other keys in it, and returns the resulting string. If the specified key is missing, an empty string is returned.
CtxIs(str key) bool
The CtxIs function returns true if there is a value with the specified key in the context. Otherwise, it returns false.
CtxSet(str key, str val) str
The CtxSet function adds a key and a value to the context. If the key already exists, it will be assigned a new value. The function returns the value of the key.
CtxSet(str key, bool b) str
The CtxSet function adds a key and a logical value b to the context. A boolean value will be converted to the string true or false. The function returns the value of the key.
CtxSet(str key, float f) str
The CtxSet function adds a key and a floating-point number f to the context. The number will be converted to a string. The function returns the value of the key.
CtxSet(str key, int i) str
The CtxSet function adds a key and an integer i to the context. The number will be converted to a string. The function returns the value of the key.
CtxValue(str key) str
The CtxValue function returns the value of the key key as is. Unlike the CtxGet function, it does not replace occurrences of other keys. If the specified key is missing, an empty string is returned.
Last updated