IO
IO
The IO module provides functions for input and output operations, environment handling, file streaming, server control, and argument parsing in SCM.
← Back to Full SCM API documentation
Prints values to stdout (only in IO environment)
Allowed number of parameters: 1–1000
Parameters:
- value... (
any
): values to print
Returns: bool
env
returns the content of a environment variable
Allowed number of parameters: 1–2
Parameters:
- var (
string
): envvar - default (
string
): default if the env is not found
Returns: string
help
Lists all functions or prints help for a specific function
Allowed number of parameters: 0–1
Parameters:
- topic (
string
): function to print help about
Returns: nil
import
Imports a .scm file into current namespace
Allowed number of parameters: 1–1
Parameters:
- filename (
string
): filename relative to folder of source file
Returns: any
load
Loads a file or stream and returns the string or iterates line-wise
Allowed number of parameters: 1–3
Parameters:
- filenameOrStream (
string|stream
): filename or stream - linehandler (
func
): handler for each line - delimiter (
string
): delimiter for line extraction
Returns: string|bool
stream
Opens a file readonly as stream
Allowed number of parameters: 1–1
Parameters:
- filename (
string
): filename
Returns: stream
watch
Loads a file and calls a callback whenever the file changes
Allowed number of parameters: 2–2
Parameters:
- filename (
string
): filename - updatehandler (
func
): handler that receives content
Returns: bool
serve
Opens a HTTP server at a given port
Allowed number of parameters: 2–2
Parameters:
- port (
number
): port number - handler (
func
): lambda(req res)
Returns: bool
serveStatic
Creates a static handler for use in (serve)
Allowed number of parameters: 1–1
Parameters:
- directory (
string
): folder with files
Returns: func
mysql
Opens a MySQL server with custom handlers
Allowed number of parameters: 4–4
Parameters:
- port (
number
): port - getPassword (
func
): password resolver - schemacallback (
func
): schema access checker - handler (
func
): SQL handler
Returns: bool
password
Hashes a password with sha1
Allowed number of parameters: 1–1
Parameters:
- password (
string
): plain text password
Returns: string
args
Returns command line arguments
Allowed number of parameters: 0–0
Parameters: _none_
Returns: list
arg
Gets a command line argument value
Allowed number of parameters: 2–3
Parameters:
- longname (
string
): long argument name - shortname (
string
): short argument or default - default (
any
): fallback value
Returns: any