Return to index

internal functions

previous_bool = ansi(bool)

top

Enable (default) or disable ANSI colour support at runtime. Returns the previous state.

Example:

# Example for ansi
prev = ansi(true)
println "ANSI mode was: " + as_string(prev)
ansi(false)


int = argc()

top

CLI argument count.

Example:

# Example for argc
println argc()


[]string = argv()

top

CLI arguments as an array.

Example:

# Example for argv
try
    println argv(0)
catch err
    println "No command-line arguments available"
endtry


[]string = array_colours([]string)

top

Set colour scheme for array depth formatting and return previous colours.

Example:

# Example for array_colours
println array_colours(["[#red]", "[#green]", "[#blue]"])


array_format(bool)

top

Enable/disable pretty array formatting. Default: false, enabled in interactive mode.

Example:

# Example for array_format
array_format(true)


string = ast(fn_name)

top

Return tokenised phrase representation.

Example:

# Example for ast
println ast("println 42")


integer microseconds = async_wait_startup(handle_map)

top

Blocks until every async task in the handle map has begun executing. Returns the total time blocked in microseconds, or nil if the map is empty. Errors if the handle map is undeclared.

Example:

# Example for async_wait_startup
try
    var h = map(.job 1)
    async_wait_startup(h)
catch err
    println "Async wait failed"
endtry


[]result = await(handle_map[,all_flag])

top

Checks for async completion.

Example:

# Example for await
var h = map(.job 1)
println await(h)


string = bash_versinfo()

top

Returns the major version number of the Bash co-process.

Example:

# Example for bash_versinfo
println bash_versinfo()


string = bash_version()

top

Returns the full release string of the Bash co-process.

Example:

# Example for bash_version
println bash_version()


capture_shell(bool)

top

Select if | and =| commands should capture output.

Example:

# Example for capture_shell
println capture_shell(true)


clear_line(row,col)

top

Clear to the end of the line, starting at row,col in the current pane.

Example:

# Example for clear_line
try
    clear_line(0, 0)
catch err
    println "Clear line failed"
endtry


int = clktck()

top

Get clock ticks from aux file.

Example:

# Example for clktck
println clktck()


coproc(bool)

top

Select if | and =| commands should execute in the coprocess (true) or the current Za process (false).

Example:

# Example for coproc
println coproc(true)


cursoroff()

top

Disables cursor display.

Example:

# Example for cursoroff
cursoroff()


cursoron()

top

Enables cursor display.

Example:

# Example for cursoron
cursoron()


cursorx(n)

top

Moves cursor to horizontal position n.

Example:

# Example for cursorx
cursorx(10)


bool = defined(string)

top

checks if a constant, variable, or map key is defined in the current scope or USE chain

Example:

# Example for defined
myvar = 42
println defined("myvar")


dump(function_name)

top

Displays in-scope variable list.

Example:

# Example for dump
println dump()


copy = dup(map/array)

top

returns a duplicate copy of argument 1.

Example:

# Example for dup
println dup(map(.a "1", .b "2"))


bool = echo([bool[,mask]])

top

Enable or disable local echo. Optionally, set the mask character to be used during input.


Current visibility state is returned when no arguments are provided.

Example:

# Example for echo
echo(true)  # usage


[]mixed = enum_all(enum)

top

returns the values associated with enumeration enum

Example:

# Example for enum_all
enum fruits(apple, banana, cherry)
println enum_all("fruits")


[]string = enum_names(enum)

top

returns the name labels associated with enumeration enum

Example:

# Example for enum_names
enum fruits(apple, banana, cherry)
println enum_names("fruits")


[mixed] = eval(string)

top

evaluate expression in string.

Example:

# Example for eval
println eval("1 + 1")


return_values = exec(string)

top

execute code in string.

Example:

# Example for exec
try
    exec("println 42")
catch err
    println "exec not permitted"
endtry


string = execpath()

top

Returns the initial working directory.

Example:

# Example for execpath
println execpath()


bool = expect([]arguments,variant_count,[]variants)

top

returns true if the arguments satisfy the type list.

a variant is an argument count followed by a list of type_strings.

Example:

# Example for expect
try
    expect(true, "test")
catch err
    println "Expect failed"
endtry


bool = exreg(name_string,severity_string)

top

Register a new exception type in the ex enum with severity level. Returns true if successful, false if exception already exists. Severity levels: emerg, alert, crit, err, warn, notice, info, debug. Used to override default LOG level during exception handling.

Example:

# Example for exreg
println exreg("my_error", "warn")


string = format_stack_trace([]stackFrame)

top

formats a stack trace array into a readable string with numbered frames.

Example:

# Example for format_stack_trace
try
    panic("test")
catch err
    println format_stack_trace(err["stack_trace"])
endtry


[]string = func_categories()

top

Returns a list of standard library functions.

Example:

# Example for func_categories
println func_categories()


[]string = func_descriptions()

top

Returns a list of standard library function descriptions.

Example:

# Example for func_descriptions
println func_descriptions()


[]string = func_inputs()

top

Returns a list of standard library function inputs.

Example:

# Example for func_inputs
println func_inputs()


[]string = func_outputs()

top

Returns a list of standard library function outputs.

Example:

# Example for func_outputs
println func_outputs()


func_ref_num = funcref(name)

top

Find a function handle.

Example:

# Example for funcref
def myfunc()
    return 42
endfunc
println funcref("myfunc")
println funcref("nonexistent_function")


string = funcs([partial_match[,bool_return]])

top

Returns a list of standard library functions.

Example:

# Example for funcs
println funcs("", true)


int = get_col()

top

reads the column position of console text cursor.

Example:

# Example for get_col
println get_col()


int = get_cores()

top

Returns the CPU core count.

Example:

# Example for get_cores
println get_cores()


struct = get_mem()

top

Returns the current heap allocated memory and total system memory usage in MB.


Structure fields are .alloc and .system for allocated space and total system space respectively.

Example:

# Example for get_mem
get_mem()  # usage


int = get_row()

top

reads the row position of console text cursor.

Example:

# Example for get_row
println get_row()


bool = has_colour()

top

Check if tty supports at least 16 colours.

Example:

# Example for has_colour
println has_colour()


bool = has_shell()

top

Check if a child co-process has been launched.

Example:

# Example for has_shell
println has_shell()


bool = has_term()

top

Check if executing with a tty.

Example:

# Example for has_term
println has_term()


string = home()

top

Returns the home directory of the user that launched Za as reported by the coprocess.

Example:

# Example for home
println home()


string = hostname()

top

Returns the current hostname.

Example:

# Example for hostname
println hostname()


[]string = import_errors(module_alias_string)

top

Returns a list of import errors for an AUTO module. Each error message describes a struct/union that was skipped due to unresolvable fields. Returns empty list if no errors.

Example:

# Example for import_errors
println import_errors("nonexistent_module")


bool = import_has_errors(module_alias_string)

top

Returns true if an AUTO module import had any errors (structs skipped). Useful for quick checks before using optional structs.

Example:

# Example for import_has_errors
println import_has_errors("nonexistent_module")


bool = interpol(bool)

top

Enable (default) or disable string interpolation at runtime.


This is useful for ensuring that braced phrases remain unmolested. Returns the previous state.

Example:

# Example for interpol
interpol(true)  # usage


bool = key(ary_name,key_name)

top

Does key key_name exist in associative array ary_name?

Example:

# Example for key
mydata = map(.name "Alice", .age 30)
println key("mydata", "name")
println key("mydata", "city")


int = keypress([timeout_ms])

top

Returns an integer corresponding with a keypress.


Internally, the minimum timeout value is currently 1 decisecond.


See the termios(3) man page for reasoning about VMIN/VTIME.

Example:

# Example for keypress
keypress()  # usage


string = lang()

top

Returns the locale name used within the coprocess.

Example:

# Example for lang
println lang()


int = last()

top

Returns the last received error code from a co-process command.

Example:

# Example for last
println last()


string = last_err()

top

Returns the last received error text from the co-process.

Example:

# Example for last_err
println last_err()


integer = len(various_types)

top

Returns length of string or list.

Example:

# Example for len
println len([1, 2, 3, 4, 5])


value = local(string)

top

Return this local variable's value.

Example:

# Example for local
try
    println local("myvar")
catch err
    println "local variable not found"
endtry


struct = log_queue_status()

top

Returns logging queue status: .used: current queue usage, .total: queue size, .running: worker status, .percentage: usage percentage

Example:

# Example for log_queue_status
println log_queue_status()


struct = logging_stats()

top

Returns comprehensive logging statistics: .queue_used: current queue usage, .queue_total: queue size, .queue_running: worker status, .main_processed: main log requests processed, .web_processed: web access log requests processed

Example:

# Example for logging_stats
println logging_stats()


mdump(function_name)

top

Displays global variable list.

Example:

# Example for mdump
mdump()


string = os()

top

Returns the kernel version name as reported by the coprocess.

Example:

# Example for os
println os()


int = pane_c()

top

Returns the current pane start column.

Example:

# Example for pane_c
println pane_c()


int = pane_h()

top

Returns the current pane height.

Example:

# Example for pane_h
println pane_h()


int = pane_r()

top

Returns the current pane start row.

Example:

# Example for pane_r
println pane_r()


int = pane_w()

top

Returns the current pane width.

Example:

# Example for pane_w
println pane_w()


panic(message_string)

top

Calls Go's built-in panic() with the specified message. This tests the panic-to-exception conversion system when error_style() is set to 'exception' or 'mixed'.

Example:

# Example for panic
try
    panic("test")
catch err
    println "Caught panic"
endtry


permit(behaviour_string,various_types)

top

Set a run-time behaviour... uninit: should stop for uninitialised variables / dupmod: ignore duplicate imports


exitquiet: shorter error message / shell: permit shell commands / eval: permit eval() calls


interpol: permit string interpolation / cmdfallback: shell call on eval failure (interactive)


permit: enable/disable permit() / exception_strictness: enable/disable exception_strictness call


macro: enable/disable macro statement / sanitisation: enable/disable the sanitisation_enable() call

Example:

# Example for permit
permit("error_exit", true)


int = pid()

top

Return the pid of the current process.

Example:

# Example for pid
println pid()


int = ppid()

top

Return the pid of parent process.

Example:

# Example for ppid
println ppid()


string = release_id()

top

Returns the /etc derived release name.

Example:

# Example for release_id
println release_id()


string = release_name()

top

Returns the OS release name as reported by the coprocess.

Example:

# Example for release_name
println release_name()


string = release_version()

top

Returns the OS version number.

Example:

# Example for release_version
println release_version()


integer = rlen(string)

top

Returns length of string in runes.

Example:

# Example for rlen
println rlen("hello")
println rlen("hello \u4e16\u754c")


set_depth(int_max_depth)

top

Sets the maximum directory recurse depth in interactive help mode.

Example:

# Example for set_depth
set_depth(5)


int = shell_pid()

top

Get process ID of the launched child co-process.

Example:

# Example for shell_pid
println shell_pid()


uint = sizeof(string)

top

returns the size of an object.

Example:

# Example for sizeof
println sizeof([1, 2, 3, 4, 5])


string = system(string[,bool])

top

Executes command string and returns a command structure (bool==false) or displays (bool==true) the output.

Example:

# Example for system
println system("echo hello world", false)


struct = sysvar(system_variable_name)

top

Returns the value of a system variable.

Example:

# Example for sysvar
println sysvar("home")
println sysvar("unknown_var")


string = term()

top

Returns the OS reported terminal type.

Example:

# Example for term
println term()


int = term_h()

top

Returns the current terminal height.

Example:

# Example for term_h
println term_h()


int = term_w()

top

Returns the current terminal width.

Example:

# Example for term_w
println term_w()


string = thisfunc()

top

Find this function's name.

Example:

# Example for thisfunc
println thisfunc()


func_ref_num = thisref()

top

Find this function's handle.

Example:

# Example for thisref
println thisref()


struct = tokens(string)

top

Returns a structure containing a list of tokens (.tokens) in a string and a list (.types) of token types.

Example:

# Example for tokens
println tokens("hello world 42")


trap(trap_type_string,function_call_string)

top

set a responding function for a given trap type.

Currently supported trap types: int, error

Example:

# Example for trap

def cleanup()
  println "**break"
  exit 1
end

trap("int", "cleanup()")

while
  pause 1000
endwhile


bool = unmap(ary_name,key_name)

top

Remove a map key. Returns true on successful removal.

Example:

# Example for unmap
m = map(.a 1, .b 2)
println unmap("m", "a")


string = user()

top

Returns the parent user of the Bash co-process.

Example:

# Example for user
println user()


bool = utf8supported()

top

Is the current language utf-8 compliant? This only works if the environmental variable LANG is available.

Example:

# Example for utf8supported
println utf8supported()


uint = varbind(string)

top

returns the name binding uint for a variable.

Example:

# Example for varbind
try
    println varbind("myvar")
catch err
    println "varbind failed"
endtry


bool = winterm()

top

Is this a WSL terminal?

Example:

# Example for winterm
println winterm()


struct = zainfo()

top

internal info: .version: semantic version number, .name: language name, .build: build type

Example:

# Example for zainfo
println zainfo()


string = zsh_version()

top

Returns the zsh version string if present.

Example:

# Example for zsh_version
println zsh_version()