UNIX

< Show List

Commands and functions specific to UNIX or linux implementations.


UNIX Commands


gotoxy VAL, VAL

Sets the horizontal and vertical location of the text output cursor using vt100/xterm control characters. (0,0) is the upper left corner.


open STRINGEXPR for input as # FNUM

Where STRINGEXPR start with the string: "pipe:"

Opens an input pipe with STRINGEXPR as the input process command string.

Example:
open "pipe:/bin/ls -l" for input as #1

open STRINGEXPR , INTEXPR for input as # FNUM

open STRINGEXPR , INTEXPR for output as # FNUM

Where STRINGEXPR start with the string: "socket:"

Opens a socket with STRINGEXPR as the hostname and INTEXPR as the port number. The input needs to be opened before the output.

Example:
open "socket:foo.net",7 for input as #3 : rem echo port
open "socket:foo.net",7 for output as #4
print #4, "hello"
input #3, a$
close #4 : close #3

UNIX Functions

With a UNIX/linux/Mac OS X command line version of Chipmunk Basic, the following commands are very powerful. Using them, Chipmunk Basic can be used to write shell scripts, control other programs, and do all manner of mischief.


#cbas#run_only

When used in a Basic program file, upon load, sets the Chipmunk Basic interpreter to run-only mode, interactive mode disabled. The STOP and END commands and the use of Ctrl-C will quit the interpreter. Insert #!/basic along with this command as the first two lines of your program, chmod +x it, and you've got an executable script written in Chipmunk Basic!


sys( STRINGVAL )

UNIX system call. The string parameter is given to the shell as a command. Returns exit status.


getenv$( STRINGVAL )

Returns value for environment name STRINGVAL.


argv$

Returns the UNIX shell command line arguments. The first two are always "basic" and the name of the program file, at least under Mac OS X.