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
ansi(false)  # disable ANSI


int = argc()

top

CLI argument count.

Example:

# Example for argc
println argc()  # e.g., 1


[]string = argv()

top

CLI arguments as an array.

Example:

# Example for argv
println argv()  # e.g., ["file.za","arg1","arg2"]


[]string = array_colours([]string)

top

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


array_format(bool)

top

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


string = ast(fn_name)

top

Return tokenised phrase representation.

Example:

# Example for ast
println ast("myfunction")


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

top

Checks for async completion.

Example:

# Example for await
var h={"job": 1}
println await(h)  # list of results


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
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
clear_line(10,0)


int = clktck()

top

Get clock ticks from aux file.

Example:

# Example for clktck
println clktck()  # e.g., 100


coproc(bool)

top

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

Example:

# Example for coproc
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


dump(function_name)

top

Displays in-scope variable list.


copy = dup(map/array)

top

returns a duplicate copy of argument 1.


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

top

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

[#SOL]Current visibility state is returned when no arguments are provided.

Example:

# Example for echo
println echo(false)  # disables local echo


[]mixed = enum_all(enum)

top

returns the values associated with enumeration enum

Example:

# Example for enum_all
enum e(ok=0,one,two,three)
println enum_all(e)  # [0,1,2,3]


[]string = enum_names(enum)

top

returns the name labels associated with enumeration enum

Example:

# Example for enum_names
println enum_names(e)  # ["ok","one","two","three"]


[mixed] = eval(string)

top

evaluate expression in string.

Example:

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


return_values = exec(string)

top

execute code in string.


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.


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.


string = format_stack_trace([]stackFrame)

top

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


[]string = func_categories()

top

Returns a list of standard library functions.


[]string = func_descriptions()

top

Returns a list of standard library function descriptions.


[]string = func_inputs()

top

Returns a list of standard library function inputs.

Example:

# Example for func_inputs
println func_inputs()  # list of function input names


[]string = func_outputs()

top

Returns a list of standard library function outputs.


func_ref_num = funcref(name)

top

Find a function handle.


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

top

Returns a list of standard library functions.


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()  # e.g., 4


struct = get_mem()

top

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

[#SOL]Structure fields are .alloc and .system for allocated space and total system space respectively.

Example:

# Example for get_mem
println get_mem().alloc  # allocated memory in MB


int = get_row()

top

reads the row position of console text cursor.

Example:

# Example for get_row
println get_row()  # e.g., 0


bool = has_colour()

top

Check if tty supports at least 16 colours.

Example:

# Example for has_colour
println has_colour()  # true/false


bool = has_shell()

top

Check if a child co-process has been launched.

Example:

# Example for has_shell
println has_shell()  # true


bool = has_term()

top

Check if executing with a tty.

Example:

# Example for has_term
println has_term()  # true


string = home()

top

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

Example:

# Example for home
println home()  # e.g., "/home/user"


string = hostname()

top

Returns the current hostname.

Example:

# Example for hostname
println hostname()  # e.g., "myhost"


[]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.


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.


bool = interpol(bool)

top

Enable (default) or disable string interpolation at runtime.

[#SOL]This is useful for ensuring that braced phrases remain unmolested. Returns the previous state.


bool = key(ary_name,key_name)

top

Does key key_name exist in associative array ary_name?

Example:

# Example for key
var m={"a":1}
println key(m,"a")  # true


int = keypress([timeout_ms])

top

Returns an integer corresponding with a keypress.

[#SOL]Internally, the minimum timeout value is currently 1 decisecond.

[#SOL]See the termios(3) man page for reasoning about VMIN/VTIME.

Example:

# Example for keypress
println keypress(1000)  # (waits for keypress, returns code)


string = lang()

top

Returns the locale name used within the coprocess.

Example:

# Example for lang
println lang()  # e.g., en_GB.UTF-8


int = last()

top

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


string = last_err()

top

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


integer = len(various_types)

top

Returns length of string or list.

Example:

# Example for len
println len("abcd")  # 4


value = local(string)

top

Return this local variable's value.


struct = log_queue_status()

top

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


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


mdump(function_name)

top

Displays global variable list.


string = os()

top

Returns the kernel version name as reported by the coprocess.

Example:

# Example for os
println os()  # e.g., "Linux 5.4.0-42-generic"


int = pane_c()

top

Returns the current pane start column.

Example:

# Example for pane_c
println pane_c()  # 0


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()  # 0


int = pane_w()

top

Returns the current pane width.

Example:

# Example for pane_w
println pane_w()  # 80


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'.


permit(behaviour_string,various_types)

top

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

[#SOL]exitquiet: shorter error message / shell: permit shell commands / eval: permit eval() calls

[#SOL]interpol: permit string interpolation / cmdfallback: shell call on eval failure (interactive)

[#SOL]permit: enable/disable permit() / exception_strictness: enable/disable exception_strictness call

[#SOL]macro: enable/disable macro statement / sanitisation: enable/disable the sanitisation_enable() call

Example:

# Example for permit
println permit("shell",false)


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()  # parent PID


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()  # e.g., "Ubuntu"


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.


set_depth(int_max_depth)

top

Sets the maximum directory recurse depth in interactive help mode.


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.


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",true)


struct = sysvar(system_variable_name)

top

Returns the value of a system variable.


string = term()

top

Returns the OS reported terminal type.


int = term_h()

top

Returns the current terminal height.

Example:

# Example for term_h
println term_h()  # e.g., 24


int = term_w()

top

Returns the current terminal width.

Example:

# Example for term_w
println term_w()  # e.g., 80


string = thisfunc()

top

Find this function's name.


func_ref_num = thisref()

top

Find this function's handle.


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
var t=tokens("a=1")
println t.tokens  # ["a","=","1"]


trap(trap_type_string,function_call_string)

top

set a responding function for a given trap type.

Currently supported trap types: int, error


bool = unmap(ary_name,key_name)

top

Remove a map key. Returns true on successful removal.

Example:

# Example for unmap
var m=map{"a":1,"b":2}
unmap("m","a")
println m  # {"b":2}


string = user()

top

Returns the parent user of the Bash co-process.

Example:

# Example for user
println user()  # e.g., "daniel"


bool = utf8supported()

top

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


uint = varbind(string)

top

returns the name binding uint for a variable.

Example:

# Example for varbind
println varbind("a")  # 1


bool = winterm()

top

Is this a WSL terminal?


struct = zainfo()

top

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


string = zsh_version()

top

Returns the zsh version string if present.

Example:

# Example for zsh_version
println zsh_version()  # e.g., 5.8