Name | Returns | Usage | Ver | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
log | string | log([number level=LOG_INFO,] value [,value])
3.11
| Add a line of text to the server and/or system log. | values are typically string constants or variables (each logged as a separate log message), level is the severity of the message to be logged, one of the globally-defined values, in decreasing severity: LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG (default: LOG_INFO) read | string | read([count=128])
| 3.11
| Read up to count characters from input stream and return as a string or undefined upon error
| readln | string | readln([count=128])
| 3.11
| Read a single line, up to count characters, from input stream and return as a string or undefined upon error
| write | void | write(value [,value])
| 3.11
| Send one or more values (typically strings) to the output stream
| write_raw | void | write_raw(value [,value])
| 3.14
| Send a stream of bytes (possibly containing NUL or special control code sequences) to the output stream
| writeln | void | writeln(value [,value])
| 3.11
| Send a line of text to the output stream with automatic line termination (CRLF), values are typically string constants or variables (AKA print)
| printf | string | printf(string format [,value][,value])
| 3.10
| Send a C-style formatted string of text to the output stream. See also the format() function.
| alert | void | alert(value)
| 3.10
| Send an alert message (ala client-side JS) to the output stream
| prompt | string | prompt([string text] [,string value] [,number k_mode=K_EDIT])
| 3.10
| Display a prompt (text) and return a string of user input (ala client-side JS) or null upon no-input | value is an optional default string to be edited (used with the k_mode K_EDIT flag) See sbbsdefs.js for all valid K_ (keyboard-input) mode flags. confirm | boolean | confirm(value)
| 3.10
| Display a Yes/No prompt and return true or false based on user's confirmation (ala client-side JS, true = yes) | see also console.yesno() deny | boolean | deny(value)
| 3.15b
| Display a No/Yes prompt and returns true or false based on user's denial (true = no) | see also console.noyes() exit | void | exit([number exit_code=0])
| 3.11
| Stop script execution, optionally setting the global property exit_code to the specified numeric value
| load | undefined | load([bool background or object scope,] string filename [,args])
| 3.12
| Load and execute a JavaScript module (filename), optionally specifying a target scope object (default: this) and a list of arguments to pass to the module (as argv). | Returns the result (last executed statement) of the executed script or a newly created Queue object if background is true). Background: When the background parameter is true, the loaded script runs in the background (in a child thread) but may communicate with the parent script/thread by reading from and/or writing to the parent_queue (an automatically created Queue object). The result (last executed statement) of the executed script (or the optional exit_code passed to the exit() function) will be automatically written to the parent_queue which may be read later by the parent script (using load_result.read(), for example). require | undefined | require([object scope,] string filename, propname [,args])
| 3.17
| Load and execute a JavaScript module (filename), optionally specifying a target scope object (default: this) and a list of arguments to pass to the module (as argv) IF AND ONLY IF the property named propname is not defined in the target scope (a defined symbol with a value of undefined will not cause the script to be loaded). | Returns the result (last executed statement) of the executed script or null if the script is not executed. mswait | number | mswait([milliseconds=1])
| 3.13
| Pause execution for the specified number of milliseconds (AKA sleep), returns elapsed duration, in seconds
| yield | void | yield([forced=true])
| 3.11
| Release current thread time-slice, a forced yield will yield to all other pending tasks (lowering CPU utilization), a non-forced yield will yield only to pending tasks of equal or higher priority. forced defaults to true
| random | number | random([max_number=100])
| 3.10
| Return random integer between 0 and max_number-1
| time | number | time()
| 3.10
| Return current time and date in Unix (time_t) format (number of seconds since January 1st, 1970 UTC)
| beep | void | beep([frequency=500] [,duration=500])
| 3.10
| Produce a tone on the local speaker at specified frequency for specified duration (in milliseconds)
| sound | boolean | sound([filename])
| 3.10
| Play a waveform (.wav) sound file (currently, on Windows platforms only)
| ctrl | string | ctrl(number or string value)
| 3.11
| Return ASCII control character representing character value passed - Example: ctrl('C') returns string containing the single character string: '\3'
| ascii | undefined | ascii([string text] or [number value])
| 3.10
| Convert single character to numeric ASCII value or vice-versa (returns number OR string)
| ascii_str | string | ascii_str(text)
| 3.10
| Convert extended-ASCII (CP437) characters in text string to plain US-ASCII equivalent, returns modified string
| strip_ctrl | string | strip_ctrl(text)
| 3.10
| Strip all control characters and Ctrl-A (attribute) sequences from string, returns modified string
| strip_ctrl_a | string | strip_ctrl_a(text)
| 3.20
| Strip all Ctrl-A (attribute) sequences from string, returns modified string
| strip_ansi | string | strip_ansi(text)
| 3.18c
| Strip all ANSI terminal control sequences from string, returns modified string
| strip_exascii | string | strip_exascii(text)
| 3.10
| Strip all extended-ASCII characters from string, returns modified string
| skipsp | string | skipsp(text)
| 3.15
| Skip (trim) white-space characters off beginning of string, returns modified string
| truncsp | string | truncsp(text)
| 3.10
| Truncate (trim) white-space characters off end of string, returns modified string
| truncstr | string | truncstr(text, charset)
| 3.10
| Truncate (trim) string at first char in charset, returns modified string
| lfexpand | string | lfexpand(text)
| 3.10
| Expand sole line-feeds (LF) to carriage-return/line-feed sequences (CRLF), returns modified string
| wildmatch | boolean | wildmatch([bool case_sensitive=false,] filename [,pattern='*'] [,path=false])
| 3.14
| Return true if the filename matches the wildcard pattern (wildcard characters supported are '*' and '?'), if path is true, '*' will not match path delimiter characters (e.g. '/')
| backslash | string | backslash(path)
| 3.12
| Return directory path with trailing (platform-specific) path delimiter (i.e. "slash" or "backslash")
| fullpath | string | fullpath(path)
| 3.15
| Create and return an absolute or full path name for the specified relative path name.
| file_getname | string | file_getname(path/filename)
| 3.11
| Return filename portion of passed path string
| file_getext | string | file_getext(path/filename)
| 3.11
| Return file extension portion of passed path/filename string (including '.') or undefined if no extension is found
| file_getcase | string | file_getcase(path/filename)
| 3.11
| Return correct case of filename (long version of filename on Windows) or undefined if the file doesn't exist
| file_cfgname | string | file_cfgname(path, filename)
| 3.12
| Return completed configuration filename from supplied path and filename, optionally including the local hostname (e.g. path/file.host.domain.ext or path/file.host.ext) if such a variation of the filename exists
| file_getdosname | string | file_getdosname(path/filename)
| 3.15
| Return DOS-compatible (Micros~1 shortened) version of specified path/filename(on Windows only) | return unmodified path/filename on other platforms file_exists | boolean | file_exists(path/filename)
| 3.10
| Verify a file's existence
| file_remove | boolean | file_remove(path/filename)
| 3.10
| Delete a file
| file_removecase | boolean | file_removecase(path/filename)
| 3.14
| Delete files case insensitively
| file_rename | boolean | file_rename(path/oldname, path/newname)
| 3.11
| Rename a file, possibly moving it to another directory in the process
| file_copy | boolean | file_copy(path/source, path/destination)
| 3.11
| Copy a file from one directory or filename to another
| file_backup | boolean | file_backup(path/filename [,level=5] [,rename=false])
| 3.11
| Backup the specified filename as filename.number.extension where number is the backup number 0 through level-1 (default backup level is 5), if rename is true, the original file is renamed instead of copied (default is false)
| file_isdir | boolean | file_isdir(path/filename)
| 3.10
| Check if specified filename is a directory
| file_attrib | number | file_attrib(path/filename)
| 3.10
| Get a file's attributes (same as file_mode() on *nix). On Windows, the return value corresponds with _finddata_t.attrib (includes DOS/Windows file system-specific attributes, like hidden, and archive). Returns -1 if the path/filename does not exist.
| file_mode | number | file_mode(path/filename)
| 3.17c
| Get a file's type and mode flags (e.g. read/write/execute permissions). The return value corresponds with struct stat.st_mode. Returns -1 if the path/filename does not exist.
| file_chmod | number | file_chmod(path/filename, number mode)
| 3.17c
| Set a file's permissions flags. The supported mode bit values are system-dependent (e.g. Windows only supports setting or clearing the user-write/0x80 mode flag). Returns true if the requested change was successful.
| file_date | number | file_date(path/filename)
| 3.10
| Get a file's last modified date/time (in time_t format). Returns -1 if the path/filename does not exist.
| file_cdate | number | file_cdate(path/filename)
| 3.17
| Get a file's creation date/time (in time_t format). Returns -1 if the path/filename does not exist.
| file_size | number | file_size(path/filename)
| 3.10
| Get a file's length (in bytes). Returns -1 if the path/filename does not exist.
| file_utime | boolean | file_utime(path/filename [,access_time=current] [,mod_time=current])
| 3.11
| Change a file's last accessed and modification date/time (in time_t format), or change to current time
| file_touch | boolean | file_touch(path/filename)
| 3.11
| Update a file's last modification date/time to current time, creating an empty file if it doesn't already exist
| file_mutex | boolean | file_mutex(path/filename [,string text=local_hostname] [,number max_age=0])
| 3.12
| Attempt to create an mutual-exclusion (e.g. lock) file, optionally with the contents of text. If a non-zero max_age is specified and the lock file exists, but is older than this value (in seconds), it is presumed stale and removed/over-written
| file_compare | boolean | file_compare(path/file1, path/file2)
| 3.14
| Compare 2 files, returning true if they are identical, false otherwise
| directory | array | directory(path/pattern [,flags=GLOB_MARK])
| 3.10
| Return an array of directory entries, pattern is the path and filename or wildcards to search for (e.g. '/subdir/*.txt'), flags is a set of optional glob bit-flags (default is GLOB_MARK)
| dir_freespace | number | dir_freespace(directory [,unit_size=1])
| 3.11
| Return the amount of available disk space in the specified directory using the specified unit_size in bytes (default: 1), specify a unit_size of 1000 to return the available space in kilobytes or 1024 for kibibytes.
| disk_size | number | disk_size(directory [,unit_size=1])
| 3.14
| Return the total disk size of the specified directory using the specified unit_size in bytes (default: 1), specify a unit_size of 1000 to return the total disk size in kilobytes or 1024 for kibibytes.
| socket_select | array | socket_select([array of socket objects or descriptors] [,number timeout=0] [,bool write=false])
| 3.11
| Check an array of socket objects or descriptors for read or write ability (default is read), default timeout value is 0.0 seconds (immediate timeout), returns an array of 0-based index values into the socket array, representing the sockets that were ready for reading or writing, or null on error. If multiple arrays of sockets are passed, they are presumed to be in the order of read, write, and except. In this case, the write parameter is ignored and an object is returned instead with up to three properties "read", "write", and "except", corresponding to the passed arrays. Empty passed arrays will not have a corresponding property in the returned object.
| socket_strerror | string | socket_strerror(error)
| 3.18c
| Get the description(string representation) of a numeric socket error value (e.g. socket_errno)
| strerror | string | strerror(error)
| 3.18c
| Get the description(string representation) of a numeric system error value (e.g. errno)
| mkdir | boolean | mkdir(path/directory)
| 3.10
| Make a directory on a local file system
| mkpath | boolean | mkpath(path/directory)
| 3.15
| Make a path to a directory (creating all necessary sub-directories). Returns true if the directory already exists.
| rmdir | boolean | rmdir(path/directory)
| 3.10
| Remove a directory
| rmfiles | boolean | rmfiles(path/directory [,file-spec='*'] [,files-to-keep=0])
| 3.20
| Remove all files and sub-directories in the specified directory, recursively - use with caution!
| strftime | string | strftime(format [,time=current])
| 3.10
| Return a formatted time string (ala the standard C strftime function)
| format | string | format(format [,args])
| 3.10
| Return a C-style formatted string (ala the standard C sprintf function)
| html_encode | string | html_encode(text [,bool ex_ascii=true] [,bool white_space=true] [,bool ansi=true] [,bool ctrl_a=true] [, state (object)])
| 3.11
| Return an HTML-encoded text string (using standard HTML character entities), escaping IBM extended-ASCII (CP437), white-space characters, ANSI codes, and CTRL-A codes by default.Optionally storing the current ANSI state in state object
| html_decode | string | html_decode(html)
| 3.11
| Return a decoded HTML-encoded text string, translating HTML character entities into CP437 character equivalents
| word_wrap | string | word_wrap(text [,line_length=79 [,orig_line_length=79 [,bool handle_quotes=true [,bool is_utf8=false]]]])
| 3.11
| Return a word-wrapped version of the text string argument optionally handing quotes magically, line_length defaults to 79, orig_line_length defaults to 79, handle_quotes defaults to true, and is_utf8 defaults to false | Note: if the original text does not contain any carriage-return (CR) characters, lines are wrapped with sole line-feed (LF) characters. quote_msg | string | quote_msg(text [,line_length=79] [,prefix=" > "])
| 3.11
| Return a quoted version of the message text string argument, line_length defaults to 79, prefix defaults to " > "
| rot13_translate | string | rot13_translate(text)
| 3.11
| Return ROT13-translated version of text string (will encode or decode text)
| base64_encode | string | base64_encode(text)
| 3.11
| Return base64-encoded version of text string or null on error
| base64_decode | string | base64_decode(text)
| 3.11
| Return base64-decoded text string or null on error
| crc16_calc | number | crc16_calc(text)
| 3.11
| Calculate and return 16-bit CRC of text string
| crc32_calc | number | crc32_calc(text)
| 3.11
| Calculate and return 32-bit CRC of text string
| chksum_calc | number | chksum_calc(text)
| 3.11
| Calculate and return 32-bit checksum of text string
| md5_calc | string | md5_calc(text [,bool hex=false])
| 3.11
| Calculate and return 128-bit MD5 digest of text string, result encoded in base64 (default) or hexadecimal
| sha1_calc | string | sha1_calc(text [,bool hex=false])
| 3.19
| Calculate and return 160-bit SHA-1 digest of text string, result encoded in base64 (default) or hexadecimal
| resolve_ip | string | resolve_ip( | |