General & Logical Functions


  • IF Returns one value if a condition evaluates to TRUE, and another value if that condition evaluates to FALSE.
  • CHOOSE Uses index number to return a value from the list of value arguments.
  • TEMP_FILENAME Returns a name for a temporary file.
  • RAND Returns a pseudorandom number.
  • ISNUMBER Returns a boolean value indicating whether an expression can be converted to a number.
  • ISDATE Returns a boolean value indicating whether an expression can be converted to a datetime value.
  • ISBOOL Returns a boolean value indicating whether an expression can be converted to a boolean value.
  • ISADMIN Test if the current player process has the administrator privilege.
  • TOSTRING Converts an expression into a string.
  • TONUMBER Converts an expression into a number.
  • TODATE Converts an expression into a date value.
  • TOBOOL Converts an expression into a boolean value.
  • TOHEXSTR Convert a number into hexadecimal representation.
  • XLSCOL_TONAME Converts an index number to the Microsoft Excel column name.
  • XLSCOL_TOINDEX Converts a Microsoft Excel column name to an index number.

IF

Returns one value if a condition evaluates to TRUE, and another value if that condition evaluates to FALSE.

value IF( logical_exp, [value_if_true, value_if_false] )

Note: If the value_if_true argument or value_if_false is omitted, the boolean value TRUE or FALSE will be returned.

Examples:

IF( 20 > 10, "OK", "FALSE" ) //return the string "OK"

IF( 20 < 10, "OK", 100 ) //return the number 100

IF( 20 < 10 ) //return the boolean value FALSE because the parameter value_if_false is omitted.

CHOOSE

Uses index number to return a value from the list of value arguments.

value CHOOSE( exp_of_index_number, value1, [value2, ...] )

Note: If exp_of_index_number is 0, CHOOSE returns value1; if it is 1, CHOOSE returns value2; and so on. If exp_of_index_number is less than 0 or greater than the number of the last value in the list, CHOOSE causes an error.

Examples:

CHOOSE( 3 - 3, "One", "Two", "Three", "Four" ) //return the string "ONE"

TEMP_FILENAME

Returns a name for a temporary file.

string TEMP_FILENAME( [prefix_string],[bool_contain_path] )

Note: The function uses up to the first three characters of this string as the prefix of the file name. The default value of the parameter bool_contain_path is FALSE.

  • temp_filename() //23123.tmp
  • temp_filename( "abc" ) //abc3123.tmp
  • temp_filename( "abc", true ) //c:\users\john\appdata\local\temp\abc3123.tmp

RAND

Returns a pseudorandom number.

number RAND( [num_min, num_max] )

Note: The default value of the optional parameter num_min is zero, and the num_max is 2147483647.

ISNUMBER

Returns a boolean value indicating whether an expression can be converted to a number.

boolean ISNUMBER( expression )

ISDATE

Returns a boolean value indicating whether an expression can be converted to a datetime value.

boolean ISDATE( expression )

ISBOOL

Returns a boolean value indicating whether an expression can be converted to a boolean value.

boolean ISBOOL( expression )

ISADMIN

Returns a boolean value indicating whether the curren player process has the administrator privilege.

boolean ISADMIN()

TOSTRING

Converts an expression into a string.

string TOSTRING( expression, [num_digits] )

Note: The optional parameter num_digits is only available when the first parameter is a number.

Examples:

TOSTRING( 20.4567 ) //return the string "20.4567"

TOSTRING( 20.4567, 2 ) //return the string "20.45"

TONUMBER

Converts an expression into a number.

number TONUMBER( expression )

TODATE

Converts an expression into a date value.

datetime TODATE( expression )

TOBOOL

Converts an expression into a boolean value.

boolean TOBOOL( expression )

TOHEXSTR

Convert a number into hexadecimal representation.

string TOHEXSTR( number, [bool_upper] )

Note: The default value of the optional parameter bool_upper is FALSE.

Examples:

TOHEXSTR( 106 ) //return the string "6a"

TOHEXSTR( 106, TRUE ) //return the string "6A"

XLSCOL_TONAME

Converts an index number to the Microsoft Excel column name.

string XLSCOL_TONAME( index_number )

Examples:

XLSCOL_TONAME( 0 ) //return the string "A"

XLSCOL_TONAME( 26 ) //return the string "AA"

XLSCOL_TOINDEX

Converts a Microsoft Excel column name to an index number.

number XLSCOL_TOINDEX( column_name )

Examples:

XLSCOL_TOINDEX( "A" ) //return the number 0

XLSCOL_TOINDEX( "AA" ) //return the number 26.