file access utilities
read verbs take a right argument of a filename, optionally
linked with one or two numbers (as for 1!:11):
0 = start of read (may be negative)
1 = length of read (default rest of file)
write verbs return number of characters written.
filenames may be open or boxed character strings.
string verbs write out text delimited by CRLF, and read in
text delimited by LF.
Use charsub (defined in strings.ijs) to substitute unwanted characters,
e.g. '-_' charsub fread 'mydata.dat' replaces - with _
dat fappend fl append
dat fappends fl append string
fdir file directory
ferase fl erase file
fexist fl return 1 if file exists
opt fread fl read file
freadr fl read records (flat file)
freads fl read string
dat freplace fl replace in file
opt fselect txt select file
fsize fl size of file
str fss fl string search file
oldnew fssrplc fl search and replace in file
fstamp fl file timestamp
fview fl view file
dat fwrite fl write file
dat fwrites fl write string
on error, the result is _1,
i.e. for file not found/file read error/file write error
Defined items
Name | Class | Description |
---|
fappend | Verb | append character text to file |
fappends | Verb | append character text to file. |
fdir | Verb | file directory |
ferase | Verb | erases a file |
fexist | Verb | tests if the file exists |
fread | Verb | read file |
freadr | Verb | read records from flat file |
freads | Verb | read file as string |
freplace | Verb | replace text in file |
fselect | Verb | file selection dialog |
fsize | Verb | return file size |
fss | Verb | file string search |
fssrplc | Verb | file string search and replace |
fstamp | Verb | returns file timestamp |
fview | Verb | view file |
fwrite | Verb | write text to file |
fwrites | Verb | write string to file |
fappend............. (v) append character text to file
The text is first ravelled. The file is created if necessary.
Returns number of characters written, or an error message.
form: text fappend filename
example:
'chatham' fappend 'newfile.txt'
7
fappends............ (v) append character text to file.
The text is first ravelled into a vector with each row
terminated by the CRLF pair. Any single LF or CR characters
in the text are converted into the CRLF pair.
The file is created if necessary. Returns number of characters
written, or an error message.
fdir................ (v) file directory
example:
fdir 'system\main\s*.ijs'
ferase.............. (v) erases a file
Returns 1 if successful, otherwise _1
fexist.............. (v) tests if the file exists
Returns 1 if the file exists, otherwise 0.
fread............... (v) read file
y. is filename {;start size}
x. is optional:
= b read as boxed vector
= m read as matrix
= s read as string (same as freads)
freadr.............. (v) read records from flat file
y. is filename {;record start, # of records}
records are assumed of fixed length delimited by
one (only) of CR, LF, or CRLF.
the result is a matrix of records.
freads.............. (v) read file as string
y. is filename {;start size}
x. is optional (b and m same as fread):
= b read as boxed vector
= m read as matrix
freads
freplace............ (v) replace text in file
form: dat freplace file;pos
fselect............. (v) file selection dialog
y. = DOS filespec or ''
x. = optional file type list
returns user selection
fsize............... (v) return file size
returns file size or _1 if error
fss................. (v) file string search
form: str fss file
search file for string, returning indices
fssrplc............. (v) file string search and replace
form: (old;new) fssrplc file
fstamp.............. (v) returns file timestamp
fview............... (v) view file
uses standard Windows edit control,
which is limited to around 20K size.
fwrite.............. (v) write text to file
fwrites............. (v) write string to file