Globals - WIN


See also API Reference, WIN.


Values

Window z positioning


win.WND_TOP 0 Bring window to top of parent children.
win.WND_BOTTOM 100000 Send window to bottom of parent children.


top


Window hit test


win.HT_NOWHERE 0 Hit not in window.
win.HT_CLIENT 1 Hit client area of window.
win.HT_LINEUP 2 Hit vertical scroll bar line up button.
win.HT_LINEDOWN 3 Hit vertical scroll bar line down button.
win.HT_PAGEUP 4 Hit vertical scroll bar track to page up.
win.HT_PAGEDOWN 5 Hit vertical scroll bar track to page down.
win.HT_LINELEFT 6 Hit horizontal scroll bar line left button.
win.HT_LINERIGHT 7 Hit horizontal scroll bar line right button.
win.HT_PAGELEFT 8 Hit horizontal scroll bar track to page left.
win.HT_PAGERIGHT 9 Hit horizontal scroll bar track to page right.


top


Window identifiers


win.ID_TITLEBAR 80000 Title bar window id.
win.ID_CLOSE 80001 Window close button id.


top


Clipboard data types


win.CB_EMPTY 0 Clipboard is empty.
win.CB_TEXT 1 Clipboard data is plain text.


top


Key input


win.KEYINPUT_NONE 0 No key input.
win.KEYINPUT_LINE 1 Single line key input.
win.KEYINPUT_EDIT 2 Multi-line key input.


top


fs

fs.cp

result, count, msg  fs.cp (srcpath, destpath, recurse)

Copies file or folder, overwriting if it exists.

Parameters
srcpath string
Path of existing file or folder.
destpath string Path to copy to.
recurse boolean
If true and copying folder, recursively copies contents of folder also.

Returns
result boolean True if operation succeeded, false if not. Note for folder operations some files may have been copied even if failed.
count number
The count of files and folders copied.
msg string/nil
On failure, an error message.

Remarks


top


fs.is_sub_of

result fs.is_sub_of (parent, sub)

Tests if the sub path is under the parent path.

Parameters
parent string Full parent path to check.
sub string Full sub path to test.

Returns
result boolean True if sub path is under parent path, false if not.

Remarks
This does not check the existence of the paths on disk, it just tests the path strings.


top


fs.load_ini

ini fs.load_ini (path)

Loads the ini file at path and returns a table object of the key/value pairs in the file, or nil if unsuccessful.

Parameters
path string The file path of the ini file to load. Must be the full path to the file.

Returns
ini table Table of key/value pairs, or nil if unsuccessful.

Remarks
The returned table contains an index for each key/value pair (starting from 1). Each index has two string properties; "name" and "value". The table also has two methods, find and next.

value ini:find (name)
Finds the first value for a key, or nil if none:
local ini = fs.load_ini ("/somefile.ini")

if ini then    local value = tostring ((ini:find ("key")) or "default value")    -- do something end

value  ini:next (name)
To iterate all of a given key:
local ini = fs.load_ini ("/somefile.ini")
if ini then    for value in ini:next ("key") do       -- do something    end end


top


fs.rm

result, count, msg fs.rm (path, recurse)

Deletes a file or folder.

Parameters
path string
The full path of the file or folder to delete.
recurse boolean
Deleting folders only:
If true and folder has content, recursively deletes contents of folder if not empty.
If false and folder has content, operation fails.
Ignored when deleting files.

Returns
result boolean
True if operation succeeded, false if not. Note for folder operations some files may have been deleted even if failed.
count number
The count of files and folders deleted.
msg string/nil On failure, an error message.

Remarks


top


fs.tmpfile

path fs.tmpfile (prefix)

Returns a unique path for a file/folder in the /tmp folder.

Parameters
prefix string/nil
A prefix for the file/folder name. If nil "tmp" is used.

Returns
path string The returned full path.

Remarks
This function does not check the existence of the /tmp folder.


top


os

os.reboot

os.reboot ()

Reboots the computer.

Parameters
none



Returns
none


Remarks
Re-implemented to work with WIN.


top


os.shutdown

os.shutdown ()

Shuts down the computer.

Parameters
none


Returns
none


Remarks
Re-implemented to work with WIN.


top


string

string:splice

str, remaining, new_line, mid_word string:splice (src, len)

Splices the source string up to the length given, splitting at either a hard break or space character if possible. The source string is not altered.

Parameters
src string The string to splice.
len number The maximum length of the returned string.

Returns
str string The spliced string.
remaining string/nil Any of the source string remaining after the splice. If none nil is returned.
new_line boolean True if the string was spliced for a hard or soft break, otherwise false.
mid_word
boolean
True if the string was spliced mid-word, false if not.

Remarks
Carriage return, line feed line endings are accepted as one line break when encountered.

If the string spices at a space character, the single space character at the splice point is omitted from the returned values.


top


string:trim

str string:trim (src, char)

Returns a copy of the source string with any prefixed and postfixed instances of char removed.

Parameters
src string The source string to trim.
char string/nil The character/s to trim. If more than one character only exact groups are removed. If nil a space character is assumed.

Returns
str string The trimmed string.

Remarks
See string:trim_left, string:trim_right.


top


string:trim_left

str string:trim_left (src, char)

Returns a copy of the source string with any prefixed instances of char removed.

Parameters
src string The source string to trim.
char string The character/s to trim. If more than one character only exact groups are removed. If nil a space character is assumed.

Returns
str string The trimmed string.

Remarks
See string:trim, string:trim_right.


top


string:trim_right

str string:trim_right (src, char)

Returns a copy of the source string with any postfixed instances of char removed.

Parameters
src string The source string to trim.
char string The character/s to trim. If more than one character only exact groups are removed. If nil a space character is assumed.

Returns
str string The trimmed string.

Remarks
See string:trim, string:trim_left.


top


string:wrap

lines string:wrap (src, len)

Wraps the source string to lines of the maximum length, returned as a table of successive lines.

Parameters
src string The string value to wrap.
len number The maximum character length of a line.

Returns
lines table Returned table of strings; one for each line.

Remarks
Hard break characters \r and \n are respected. If \r is immediately followed by \n the \n is ignored. If no hard break wraps at white space. If no white space wraps at len.

At least 1 string is returned.

See string.wrap_size.


top


string.wrap_size

width, height string.wrap_size (wrap_strs)

Returns the width and height of the wrapped string table.

Parameters
wrap_strs
table A table of string lines, typically returned by string:wrap.

Returns
width number The maximum character width of any line in wrapped string table.
height number The number of lines in wrapped string table.

Remarks
The width is the character length of the longest string. The height is the size of the table. If the wrapped string contains one empty string the size returned is 0, 1. If wrap_strs is not a table 0, 0 is returned.


top


win

win.create_app_frame

appFrame win.create_app_frame ()

Called in an application's program to create an instance of an applicationFrame window for the applications' main frame. After creation the returned applicationFrame should be customized for the application's specific implementation.

Parameters
none


Returns
appFrame applicationFrame The instance of the application's main frame.

Remarks
See Application Writing.


top


win.get_printers

printers win.get_printers ()

Returns a list of printer digilines channels from the /win/devices/printers file.

Parameters
none



Returns
printers
table
List of printer channels.

Remarks


top


win.load_api

result win.load_api (path, perm)

Loads an api with reference counting. The api will not be unloaded with win.unload_api until called the same number of times as win.load_api. If the api is permanently loaded it cannot be unloaded with win.unload_api.

Parameters
path string Full path to the api file to load.
perm boolean/nil If true the api is permanently loaded.

Returns
result boolean True if the api was successfully loaded, false if not.

Remarks
See win.unload_api.


top


win.parse_cmdline

args win.parse_cmdline (...)

Parses a command line entry returning the individual components.

Parameters
... string The command line to parse. May be a single or series of string values.

Returns
args table An indexed table of the command line arguments, in order. Typically the command itself is the first.

Remarks
Individual arguments containing spaces may be delimited with double quotes.


top


win.screen_to_wnd

x, y win.screen_to_wnd (wnd, x, y)

Converts screen relative coordinates to window relative coordinates.

Parameters
wnd window The window object to use for the conversion.
x number Screen relative x coordinate.
y number Screen relative y coordinate.

Returns
x number Window relative x coordinate.
y number Window relative y coordinate.

Remarks
Coordinates are zero based from top, left.

See window:screen_to_wnd, win.wnd_to_screen.


top


win.start

win.start ()

Implements any settings from the system's /win.ini file, if required, then starts the system.

Parameters
none


Returns
none


Remarks
This function never returns.


top


win.syslog

win.syslog (entry)

Creates an entry in the system's log file, at /win.log.

Parameters
entry string The log file entry to write.

Returns
none


Remarks
Two new lines are automatically written after the entry.


top


win.unload_api

win.unload_api (path)

Unloads an api loaded with win.load_api. The api will not unloaded until win.unload_api is called the same number of times as win.load_api for the same api. If the api was permanently load calling win.unload_api will have no effect.

Parameters
path string Full path of the api file to be unloaded.

Returns
none


Remarks
See win.load_api.


top


win.version

ver win.version ()

Returns the running version of WIN.

Parameters
none



Returns
ver
number
The running version of WIN.

Remarks


top


win.wnd_to_screen

x, y win.wnd_to_screen (wnd, x, y)

Converts window relative coordinates to screen relative coordinates.

Parameters
wnd window The window object to use for the conversion.
x number Window relative x coordinate.
y
number Window relative y coordinate.

Returns
x number Screen relative x coordinate.
y
number Screen relative y coordinate.

Remarks
Coordinates are zero based from top, left.

See also window:wnd_to_screen, win.screen_to_wnd.


top


See also API Reference, WIN.