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
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 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. 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 copies files if changed form: tofile fcopynew fromfiles returns: 0, size not changed 1, size changed _1 failure copies files as strings if changed form: tofile fcopynews fromfiles returns: 0, size not changed 1, size changed _1 failure file directory example: fdir jpath '~system\main\s*.ijs' erases a file Returns 1 if successful, otherwise _1 test if a file exists Returns 1 if the file exists, otherwise 0. 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) read block of lines from file lines are terminated by LF blocksize is ~1e6 y is filename;start position returns: block;new start position 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. 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 replace text in file form: dat freplace file;pos file selection dialog y = DOS filespec or '' x = optional file type list returns user selection return file size returns file size or _1 if error file string search form: str fss file search file for string, returning indices file string search and replace form: (old;new) fssrplc file 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 |