Implement the random() function

This commit is contained in:
Gunnar Beutner 2014-11-03 17:21:33 +01:00
parent aa94563eb5
commit 19a6a65aad
2 changed files with 2 additions and 0 deletions

View File

@ -291,6 +291,7 @@ keys(dict) | Returns an array containing the dictionary's k
string(value) | Converts the value to a string.
number(value) | Converts the value to a number.
bool(value) | Converts the value to a bool.
random() | Returns a random value between 0 and RAND_MAX (as defined in stdlib.h).
log(value) | Writes a message to the log. Non-string values are converted to a JSON string.
log(severity, facility, value) | Writes a message to the log. `severity` can be one of `LogDebug`, `LogNotice`, `LogInformation`, `LogWarning`, and `LogCritical`. Non-string values are converted to a JSON string.
exit(integer) | Terminates the application.

View File

@ -41,6 +41,7 @@ REGISTER_SCRIPTFUNCTION(range, &ScriptUtils::Range);
REGISTER_SCRIPTFUNCTION(exit, &ScriptUtils::Exit);
REGISTER_SCRIPTFUNCTION(typeof, &ScriptUtils::TypeOf);
REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys);
REGISTER_SCRIPTFUNCTION(random, &Utility::Random);
bool ScriptUtils::Regex(const String& pattern, const String& text)
{