Intrinsic Functions

From SphereWiki
Revision as of 21:48, 1 November 2013 by RanXerox (talk | contribs) (added reference to UVAL)
Jump to: navigation, search
Help
Available languages


Intrinsic functions are special functions that can only be used within evaluation functions, such as EVAL, FEVAL, FHVAL, FVAL, HVAL, and UVAL. Some of the builtin functions and properties will automatically evaluate their parameters, for example the IF, WHILE statements will automatically evaluate their conditions.


Unlike the syntax for normal functions (<FUNCTION args>), the syntax for returning a value from an instrinsic function is:


FUNCTION(args)


The following table details all of the intrinsic functions in SphereServer:

Name Description
COS(value) Returns the cosine of value.
ID(defname) Returns the numeric value of defname.
ISOBSCENE(text) Returns 1 if text is considered to contain obscene language.
ISNUMERIC(value) Returns 1 if value is numeric.
LOGARITHM(value) Returns the base-10 logarithm of value.
LOGARITHM(value, base) Returns the base-base logarithm of value. (Accepts "e" and "pi" as bases, as well as numeric values)
NAPIERPOW(value) Returns e (2.7182818) to the power of value.
QVAL(a, b, less_than, equal_to, greater_than) Returns less_than if a is less than b, equal_to is a is equal to b, or greater_than if a is greater than b.
RAND(value) Returns a random value between 0 value-1.
RAND(min, max) Returns a random value between min and max.
RANDBELL(value, variance) Calculates a value based on a bell-shaped curve.
SIN(value) Returns the sine of value.
STRCMP(string1, string2) Compares string1 to string2 and returns the result. Case-sensitive. (<= 1 = string1 less than string2, 0 = string1 equal to string2, >= 1 = string1 greater than string2)
STRCMPI(string1, string2) Compares string1 to string2 and returns the result. Case-insenstive. (<= 1 = string1 less than string2, 0 = string1 equal to string2, >= 1 = string1 greater than string2)
STRINDEXOF(text, search, n) Returns the index of the search string within text, starting from the nth character. (zero-based)
STRLEN(text) Returns the length of text.
STRMATCH(pattern, text) Returns 1 if text matches the specified wildcard pattern.
STRREGEX(pattern, text) Returns 1 if text matches the specified regular expression pattern.
SQRT(value) Returns the square root of value.
TAN(value) Returns the tangent of value.