File and Device I/O

To do input or output on a file or device you must first open the file or device, then use the routines below to read or write to it, then close the file or device. open() returns a file number to use as the first argument of the other I/O routines. Certain files/devices are opened for you automatically (as text files):
0 - standard input
1 - standard output
2 - standard error
Unless you redirect them on the command-line, standard input comes from the keyboard, standard output and standard error go to the screen. When you write something to the screen it is written immediately without buffering. If you write to a file, your characters are put into a buffer until there are enough of them to write out efficiently. When you close() or flush() the file or device, any remaining characters are written out. Input from files is also buffered. When your program terminates, any files that are still open will be closed for you automatically.

open - open a file or device
close - close a file or device
flush - flush out buffered data to a file or device
puts - output a string to a file or device
printf - formatted print to a file or device
sprintf - formatted print returned as a string
print - print a Phix object with {,,} to show the structure
sprint - return a printed Phix object as a string
? x - shorthand for print(1, x)
getc - read the next character from a file or device
gets - read the next line from a file or device
get_text - read a whole text file as a single string or sequence of lines
seek - move to any byte position within an open file
where - report the current byte position in an open file
lock_file - lock a file or device
unlock_file - unlock a file or device
get_key - check for key pressed by the user, do not wait
wait_key - wait for user to press a key
dir - return complete info on all files in a directory
walk_dir - recursively walk through all files in a directory
current_dir - return the name of the current directory
chdir - change to a new current directory