classes aopen gets scanvar wopen chooser isopen seek xopen close printf tell eof ropen vread getname scanstr vwrite
fobj = new File()
fobj = new File("filename")
The functionality of xopen is not implemented in this class so use that execute a sequence of interpreter commands in a file.
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
.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
.getname(strdef)
strdef
.
File
.eof()
File
.isopen()
File
.chooser()
.chooser("w,r,a,x or nothing")
.chooser("w,r,a,x 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 "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()
.