>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  User

files: 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 or unicode strings

string verbs write out text delimited with the host OS delimiter, and read in text delimited by LF.

on error, the result is 1, e.g. for file not found/file read error/file write error
Name Type Description
fappend verb append text to file
fappends verb append string to file
fapplylines adverb apply verb to lines in file delimited by LF
fcopynew verb copies files if changed
fcopynews verb copies files as strings if changed
fdir verb file directory
ferase verb erases a file
fexist verb test if a file exists
fread verb read file
freadblock verb read block of lines from 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
ftype verb file type
fwrite verb write text to file
fwrites verb write string to file

fappend

append 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

append string to file
The text is first ravelled into a vector with each row
terminated by the host delimiter.
The file is created if necessary. Returns number of characters
written, or an error message.

fapplylines

apply verb to lines in file delimited by LF

form:
    lineproc fapplylines file  NB. line terminators removed
  1 lineproc fapplylines file  NB. line terminators preserved

fcopynew

copies files if changed
form: tofile fcopynew fromfiles
returns: 0, size    not changed
         1, size    changed
         _1         failure

fcopynews

copies files as strings if changed
form: tofile fcopynews fromfiles
returns: 0, size    not changed
         1, size    changed
         _1         failure

fdir

file directory
example:
  fdir jpath '~system\main\s*.ijs'

ferase

erases a file
Returns 1 if successful, otherwise _1

fexist

test if a file exists
Returns 1 if the file exists, otherwise 0.

fread

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)

freadblock

read block of lines from file
lines are terminated by LF
blocksize is ~1e6
y is filename;start position
returns: block;new start position

freadr

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

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

replace text in file
form: dat freplace file;pos

fselect

file selection dialog
y = DOS filespec or ''
x = optional file type list
returns user selection

fsize

return file size
returns file size or _1 if error

fss

file string search
form: str fss file
search file for string, returning indices

fssrplc

file string search and replace
form: (old;new) fssrplc file

ftype

file type

return 0 = not exist
       1 = file
       2 = directory (optionally ending in path separator)


>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  User