classes aopen getname ropen unlink chooser gets scanstr vread close isopen scanvar vwrite dir mktemp seek wopen eof printf tell xopen
fobj = new File()
fobj = new File("filename")
The functionality of xopen is not implemented in this class so use
to execute a sequence of interpreter commands in a file.strdef tstr fobj.getname(tstr) xopen(tstr)
opens file1, file2, and file3 for reading, writing, and appending (respectively).objref f1, f2, f3 //declare object references f1 = new File() //state that f1, f2, and f3 are pointers to the File class f2 = new File() f3 = new File() f1.ropen("file1") //open file1 for reading f2.wopen("file2") //open file2 for writing f3.aopen("file3") //open file3 for appending to the end of the file
File
.ropen()
.ropen("name")
File
.wopen()
.wopen("name")
File
.aopen()
.aopen("name")
File
.xopen()
.xopen("name")
Note: if instead of a "name", the number 0,1,or 2 is specified then the stdin, stdout, or stderr is opened. (not implemented)
File
.close()
File
boolean = f.mktemp()
File
boolean = f.unlink()
File
.printf("format", args, ...)
printf
and the normal
hoc printf .
File
.scanvar()
fscan()
and
returns its value.
Note: in order that .eof will return true after the last number, the last digit of that number should either be the last character in the file or be followed by a newline which is the last character in the file.
File
.scanstr(strdef)
strdef
. Returns the length of a string (if failure then returns
-1 and strdef
is unchanged).
File
.gets(strdef)
File
strdef = file.getname()
strdef = file.getname(strdef)
File
strdef = file.dir()
File
.eof()
File
.isopen()
File
.chooser()
.chooser("w,r,a,x,d or nothing")
.chooser("w,r,a,x,d or nothing", "Banner", "filter", "accept", "cancel", "path")
"*.dat"
specifies the files shown
in the browser part of the chooser.
The "path" arg specifies the file or directory to use when the
browser first pops up.
The form with args sets the style of the chooser but
does not pop it up. With no args, the browser pops up and can
be called several times. Each time starting where it left
off previously.
The "d" style is used for selecting a directory (in contrast to a file). With the "d" style, three buttons are placed beneath the browser area with "Open" centered beneath the "Show", "Cancel" button pair. The "Open" button must be pressed for the dialog to return the name of the directory. The "Show" button merely selects the highlighted browser entry and shows the relevant directory contents. A returned directory string always has a final "/".
The "x" style is unimplemented. Use
The following comes courtesy of Zach Mainen, zach@helmholtz.sdsc.edu.f.chooser("", "Execute a hoc file", "*.hoc", "Execute") if (f.chooser()) { f.getname(str) xopen(str) }
File
.vwrite(&x)
.vwrite(&x, i)
.vwrite(n, &x)
.vwrite(n, &x, i)
fwrite()
. The form with two arguments specifies the
number of elements to write and the address from which to
begin writing. With one argument, n is assumed to be 1.
Must be careful that the length of x[] is at least i+n.
File
.vread(&x)
.vread(&x, i)
.vread(n, &x)
.vread(n, &x, i)
fread()
.
File
.seek()
.seek(offset)
.seek(offset,origin)
File
.tell()
.seek()
.