WDialog API for Objective Caml: Wd_var_functions
module Wd_var_functions: sig .. end This module defines the "variable functions" that can be called in
$[...] expressions. All these functions take formally a list of
var_value arguments and return a var_value . Actually, they are
often only defined for a certain number of arguments, and for arguments
of certain type.
The functions raise a Failure exception if something is wrong.
val id : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the first argument
val length : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the length of the single string argument in characters.
val card : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the cardinality of the single argument. The cardinality are the
number of iterations <ui:iterate> or <ui:enumerate> would do for a
variable with the given value:
- For a string: the number of words of the string
- For an enumerator: the number of elements
- For an association: the number of elements
val size : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the size of the single argument, which may be a String_value ,
Enum_value , Dyn_enum_value , or an Alist_value .
The returned size is encoded as String_value .
size is deprecated! Use either length or card instead!
val add : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Adds the numbers encoded as String_value , and returns the sum as
String_value .
val sub : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Subtracts the following numbers from the first number. All numbers
must be encoded as String_value . Returns the result as
String_value .
val mul : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Multiplies the numbers encoded as String_value , and returns the product
as String_value .
val div : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Divides the first number through the following numbers. All numbers
must be encoded as String_value . Returns the result as
String_value .
val modulo : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
The first number module the second number. Both numbers
must be encoded as String_value . Returns the result as
String_value .
val assoc : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Looks the second argument up in the first argument, which must be
an Alist_value . The index, i.e. second argument, must be an
String_value .
val nth : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the nth element of the first argument which must be an
Alist_value . The second argument is the position, a number encoded
as String_value .
val contains : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns 1 if the first argument contains the second argument, and 0 otherwise.
The second argument must be a string value. The function is defined as follows:
- If the first argument is a string, it is split up into a list of words,
and it is tested whether the second string occurs in the list of words.
- If the first argument is a declared enumerator, it is tested whether
the value includes the string as item.
- If the first argument is a dynamic enumerator, it is tested whether
the value includes the string as internal item.
- If the first argument is an associative list, it is tested whether
the value includes the string as index.
val mentions : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns 1 if the first argument contains the second argument, and 0 otherwise.
The second argument must be a string value. The function is defined as follows:
- If the first argument is a dynamic enumerator, it is tested whether
the value includes the string as external item.
- If the first argument is an associative list, it is tested whether
the value includes the string as mapped value.
val translate : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Like ui:translate maps internal values of enumerators to external
values. The function takes two arguments:
translate [dyn; int] : The first argument is a dynamic enumerator,
and the second argument is the internal value to translate to the
external value
translate [type; int] : The first argument denotes a declared
enumerator (as a string), and the second argument is the internal
value to translate to the external value
val rev_translate : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Maps external values to internal values:
rev_translate [dyn; int] : The first argument is a dynamic enumerator,
and the second argument is the external value to translate to the
internal value
translate [type; int] : The first argument denotes a declared
enumerator (as a string), and the second argument is the external
value to translate to the internal value
val eq : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Compares two strings, and returns 1 when equal and 0 when not equal
val ne : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Compares two strings, and returns 0 when equal and 1 when not equal
val match_ : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Checks whether the first string matches the regular expression in the
second string, and returns 1 on match and 0 otherwise
val nomatch : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Checks whether the first string matches the regular expression in the
second string, and returns 0 on match and 1 otherwise
val substring : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns a substring of the first argument, a String_value . The
following forms are accepted:
substring [s; pos; length] : The second argument is the position,
and the third argument is the length. The length can be negative.
substring [s; pos] : Only the position is passed. Returns the
substring beginning at this position until the end of the string.
If the start position or end position of the substring is outside
the possible range, only the part of the substring is returned that
is inside the possible range.
val concat : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Concatenates all the String_value arguments, and returns the
result as String_value .
val int_eq : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val int_ne : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val int_lt : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val int_le : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val int_gt : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val int_ge : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
These functions compare two strings as integers, and return 1 if the
condition is fulfilled, and 0 if not. The conditions are:
- int_eq: The integers are equal
- int_ne: The integers are not equal
- int_lt: The first integer is less than the second integer
- int_le: The first integer is less or equal than the second integer
- int_gt: The first integer is greater than the second integer
- int_ge: The first integer is greater or equal than the second integer
val int_min : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val int_max : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
These functions compute the minimum/maximum of all integer arguments
val int_abs : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val int_sign : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
These functions compute the absolute value/the sign of the first integer
argument
val card_eq : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val card_ne : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val card_lt : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val card_le : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val card_gt : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value val card_ge : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
These functions compare the cardinality of the first argument with a string taken
as integer, and return 1 if the condition is fulfilled, and 0 if not.
The cardinality is defined as for the card function.
The conditions are:
- int_eq: The cardinality is equal to the integer
- int_ne: The cardinality is not equal to the integer
- int_lt: The cardinality is less than the integer
- int_le: The cardinality is less or equal than the integer
- int_gt: The cardinality is greater than the integer
- int_ge: The cardinality is greater or equal than the integer
val height : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the height of the String_value argument. The height is
the number of lines, i.e. the number of LF/CR/CRLF occurrences
plus 1.
val width : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the width of the String_value argument. The width is
the length of the longest line (not counting the line separators).
val dialog_exists : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
When called with only one argument: The function returns 1 if the
argument is an existing dialog (i.e. Dialog_value(Some _) ) and
0 if the dialog does not exist (i.e. Dialog_value None ).
When called with two arguments (legacy mode): The first argument must
be a dialog value as before, and the second argument must be either
the string "yes" or the string "no". The function returns 1 if the
existence of the dialog is equivalent to the boolean value of the
string.
val and_ : Wd_types.dialog_type -> Wd_types.var_value Lazy.t list -> Wd_types.var_value
Calculates the logical AND operation for all its arguments: Returns 1 if
all arguments are non-zero integers, and 0 otherwise.
val or_ : Wd_types.dialog_type -> Wd_types.var_value Lazy.t list -> Wd_types.var_value
Calculates the logical OR operation for all its arguments: Returns 1 if
there is a non-zero integer as argument, and 0 otherwise.
val not_ : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Calculates the logical NOT operation of its single argument: Returns 1
if the argument is 0, and 0 if the argument is non-zero.
val true_ : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the constant 1
val false_ : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the constant 0
val if_ : Wd_types.dialog_type -> Wd_types.var_value Lazy.t list -> Wd_types.var_value
Evaluates the first argument (which must be an integer). If the integer is
non-zero, the result is the second argument. If the integer is 0, the result
is the third argument.
val var : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the contents of the variable whose name is passed as
first argument, a String_value .
val dialog : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the name of the current dialog (no arguments)
val self : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the current dialog (no arguments)
val page : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the name of the current page (no arguments)
val language : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the current language, or "" if none selected (no arguments)
val self_base_url : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the URL pointing to the current script without session state
val session_id : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Returns the session ID without checksum
val create_anchor_event : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Add an anchor event and return the identifier
val create_xanchor_event : Wd_types.dialog_type -> Wd_types.var_value list -> Wd_types.var_value
Add an indexed anchor event and return the identifier
|