This section describes the words that interact with the underlying
operating system that Until runs under.
argc
( --- argc )
"a-r-g-c". argc leaves the number of arguments from the command line on the
parameter stack. This makes passing command line arguments to Until
words easy. See argv for a complete example.
argv
( --- argv )
"a-r-g-v". argv leaves the pointer to the arguments on the command
line on the stack. This makes passing command line arguments to
Until words easy.
: test-argv
argv 20 dump cr cr
argv @ 20 dump cr cr ( argv[0] )
argv 4 + @ 20 dump cr cr ( argv[1] )
;
dir
( --- )
"dir". Executes a "dir" command to the OS. This works fine in DOS, CP/M, and
VAX/VMS. In Unix and its' clones, you must create a shell script named dir.
dir accepts no file specification. Do a directory via system
to generate a selective directory.
edit
( 'filename --- )
This word shells to the OS to execute the editor specified in
the global variable editor. The default is EMACS, except for
Coherent where the name is "me". Usage is:
" filename" edit
Once the filename has been specified in the first edit, simply use
here to edit the same file again.
errno
( --- value )
"errno". Return the value of C's errno global variable to the
top of the stack. Refer to your C compiler's documentation for
values and their meanings.
fload
( --- )
"f-load". Compile the sealed file specified as the next token
in the input stream.
fload source.bin
free
( addr --- )
"free". Return memory allocated by malloc to the system.
See malloc for an example.
get_env
( 'env-string --- )
"get-e-n-v". Retrieves the system environment variable whose
name is contained in 'env-string. The original value is
replaced with the value returned by the system.
80 string value
value " UNTIL-DIR" strcpy
value get_env
value dup count type cr
include
( --- )
"include". Compiles the file specified as the next token in the
input stream.
include source.app
Compiles the file, source.app, then returns to normal interpretation
of commands from the console.
list
( --- )
"list". Type the contents of a file. The usage is:
list filename
load
( --- )
"load". Load is not implemented. See fload or include.
malloc
( n --- addr )
"malloc". Allocate n bytes of system memory. The C malloc() function
is called. Use free to return the memory to the system when done
with it. Usage:
100 malloc
mem_ptr !
( some words )
mem_ptr @
free
realloc
( 'memory-block --- addr )
"re-alloc". Call the C function realloc() to reallocate a
block of memory. memory-block is the address of a previously
malloc'd block of memory. The return, addr, is either the
address of the newly allocated memory block or 0 on error.
shell
( --- )
"shell". Spawn/fork/whatever a shell to the OS.
shell
Log off to exit the shell and return to Until. This is exit
in DOS, Control-D in **ix, and logout in VMS.
STDIN
( --- fd-stdin )
"standard-in". Leave the file descriptor on the stack for STDIN. Most
systems open STDIN by default.
STDOUT
( --- fd-stdout )
"standard-out". Leave the file descriptor on the stack for STDOUT. Most
systems open STDOUT by default.
system
( --- )
"system". Used in the form:
" command" system
This command shells out to the operating system and executes the
command, such as dir.
Table of Contents
Next Section