OS-9 notes
The OS-9 version of Lua supports the conception of memory modules.
Any Lua text script can be compiled into binary format and stored
in the standard OS-9 memory module. The type code field in the module header is
set to Data (4), and the language field is set to CblCode (5).
In this case, when a module is started from shell, shell
will execute the special runtime program defined from the
module header language field. For example, for a CblCode
module the program named
runc will be called. The entire command line will be passed (after
standard shell substitutions) to it.
It seems, there aren't any mentions about real Cobol I-Code interpreter,
so Lua can use this Type/Language values.
Lua chunk can access their arguments via special table named argv.
The element at index 0 is always set to the script name. At index n, the table
has the total number of arguments passed to the chunk (without argv[0]),
the first argument is at index 1, etc.
New options for Lua binaries
New option added to Lua runtime engine (lua).
- -m module args
- execute module as OS-9 memory module
and pass all args to it via argv.
New options added to Lua compiler (luac).
- -x
- compile into OS-9 memory module and save output to default
execution directory
- -m
- compile into OS-9 memory module
Changes to Lua language
-
Lua accepts hexadecimal numeric constants in C-language notation (0x12FE).
This feature is not fully implemented (for example, tonumber() function
will return nil fot that numbers).
-
The token '!=' may be used as an alias to '~='
-
The symbol '!' may be used instead of '|' as a pipe symbol
(see readfrom() for description)
OSKLIB - OS-9 System Functions
This function changes the current data data directory for
a LUA program. For success it returns 0, on failure it returns nil plus
a string describing the error.
This function changes the current execution directory for
a LUA program. For success it returns 0, on failure it returns nil plus
a string describing the error.
This function causes the current process to be suspended until seconds
have elapsed or a signal is delivered. Zero is returned if the requested
time is elapsed. If sleep is interrupted by a signal, the number
of unslept seconds is returned.
| getprocessinfo([selectorstring]) |
This function returns process IDs specified by selectorstring.
When called without arguments, getprocessinfo returns a table with
all known process IDs (see table below.)
| pid |
Process id |
| ppid |
Parent process id |
| group |
Real group id |
| user |
Real user id |
| fnmatch(pattern [ ,selectorstring]) |
This function returns a table with the file listing of the directory
specified in pattern. If pattern is missing, the current
data directory is listed. The field n is set to the item's
number in the table. If this function fails, it returns nil, plus
a string describing the error. By default, '*' and '?' in the pattern don't match
a '.' at the beginning of the filenames. To suppress this behaviour, pass
"all" as selector string.
In the pattern string, '*' matches any sequence of characters, `?' matches
any character, [SET] matches any character in the specified set,
[^SET] matches any character not in the specified set. A set is composed
of characters or ranges; a range looks like character hyphen character
(as in 0-9 or A-Z). [0-9a-zA-Z_] is the set of characters allowed
in C identifiers. Any other character in the pattern must be matched
exactly. To suppress the special syntactic significance of any of '[]*?^-\',
and match the character exactly, precede it with a '\'.
NOTE:The lower/upercase leters are different!
This function returns a value approximating the current Calendar Time.
Returns -1 to indicate an error.
This function checks the file accessibility of the file named file,
for the permissions indicated in the argument mode, a string containing
any combination of the characters r,w,e,f with the following meanings:
| 'r' |
File can be read |
| 'w' |
File can be written |
| 'e' |
File can be executed (and located in the default exec directory) |
| 'f' |
File exists |
This functions displays prompt and reads from the standard input turning
off character echoing. Returns the user input string.
This functions sets the group/user ID of the current Lua process to uid.
If the call fails, nil is returned with a string describing the error,
otherwise it returns the number 0. uid must be in the
notation "gid.uid", "21.34" for example.
| stat(file [ ,selectorstring])
|
This function gets information about a file specified in file,
that can be either a string containing a valid pathname, or an userdata
object containing a file pointer (got from readfrom() or writeto()
calls, for example). If the selectorstring
argument is missing, stat returns a table with the fields shown
in the table below. If a selector string is passed as second argument,
only the value requested is returned. All fields are numeric values.
File must be an RBF file.
| mode |
File mode |
| amode |
File mode as a string (like "dsewrewr") |
| uid |
User ID of the owner of the file |
| gid |
Group ID of the owner of the file |
| size |
File size in bytes |
| mtime |
Time of last data modification |
| ctime |
Time of file creation |
Sets the signal handler. func must be a function or nil,
in which case the default signal handler is restored. The default handler
just issues an error message and terminates the program (via exit call)
func is called with one argument, which is a signal number.
| domodule(modname [, errormethod]) |
This function executes a given module as a Lua chunk. If there is any
error executing the module, it returns nil. Otherwise, it returns the values
returned by the chunk, or a non nil value if the chunk returns no
values. If provided, errormethod is temporary set as the error method,
while module runs. As an example, if errormethod is
nil, no error messages will be issued during the execution of the
module.
Written by
Ilja V.Levinson,
Yekaterinburg, Russia
Last modified: August, 5 1997