;(QUOTE (((INFILE file entries) - Read Entries from a Library file) (ARGUMENTS:) (% file - a library file name) (% entries - an individual entry name, a list of entry names or T) (DESCRIPTION: loads the listed entries (or the whole file if entries = T)) (from the file.)))
(DEFINE INFILE (F L) (FileMac F L () (COND ((ValueLoc F X) (EVAL (READ@ (ValueLoc F X))) (SETPL X (EVAL (READ))) X))))
(QUOTE ())
;(QUOTE (((OUTFILE file entries) - output new entries to a file) (ARGUMENTS:) (% file - a library file name) (% entries - a function name or a list of function names) (DESCRIPTION: Sends the listed functions (or variables) to the) (specified library file. If previous definitions are on the file) (the new ones replace the old ones.)))
(DEFINE OUTFILE (F L) (FileMac F (IF (EQ L T) () L) T (COND ((OR (VALUEP X) (GETPL X)) (COND ((NULL (DocLoc F X)) (SFP F (Eof F)) (PRIN1 (QUOTE %;)) (PRINT (LIST (QUOTE QUOTE) (LIST (APPEND (QUOTE (Please Document)) (LIST X))))) (Update F X (ADD1 (Eof F)) (Eof F)) (Eof F (GFP F)))) (Update F X (DocLoc F X) (Eof F)) (PRINT@ (Eof F) (DEFEXP X)) (PRINT (LIST (QUOTE QUOTE) (GETPL X))) (Eof F (GFP F))))))
(QUOTE ())
;(QUOTE (((DIRFILE file) - return a list of file entries) (ARGUMENT: file - a library file name) (DESCRIPTION: returns a list of the entries on file)))
(DEFINE DIRFILE (F) (FileOp F () Entrylist))
(QUOTE ())
;(QUOTE (((PURGEFILE file entries) - remove entries from a library file) (ARGUMENTS:) (% file - a library file name) (% entries - names of entries to be removed from the file) (DESCRIPTION: Erases the entries from the file (QUOTE s) internal directory.)))
(DEFINE PURGEFILE (F L) (FileMac F (IF (EQ L T) () L) T (PROGN (Directory F (LISTREM (Directory F) X)) X)))
(QUOTE ())
;(QUOTE (((EDITFILE file entries) - edit a library file) (ARGUMENTS:) (% file - a library file name) (% entries - names of entries to be edited) (DESCRIPTION: Invokes the list editor on each of the specified entries)))
(DEFINE EDITFILE (F L) (FileMac F L T (IF (ValueLoc F X) (LET ((NEWEXP (EDITL (READ@ (ValueLoc F X)))) (NEWPL (READ))) (Update F X (DocLoc F X) (Eof F)) (PRINT@ (Eof F) NEWEXP) (PRINT NEWPL) (Eof F (GFP F))))))
(QUOTE ())
;(QUOTE (((DOCFILE file entries) - document a library file) (ARGUMENTS:) (% file - a library file name) (% entries - names of file entries to be documented) (DESCRIPTION: invokes the list editor on the documentation) (for the specified entries.)))
(DEFINE DOCFILE (F L) (FileMac F L T (IF (DocLoc F X) (LET ((NEWDOC (LIST (QUOTE QUOTE) (EDITL (CADR (READ@ (DocLoc F X))))))) (Update F X (ADD1 (Eof F)) (ValueLoc F X)) (SFP F (Eof F)) (PRIN1 (QUOTE %;)) (PRINT NEWDOC) (Eof F (GFP F))))))
(QUOTE ())
;(QUOTE (((PACKFILE file) - squeeze a library file) (DESCRIPTION: Eliminates wasted or inaccessible space from a) (% library file.)))
;(QUOTE (((COPYFILE ofile nfile entries) - copy entries from one file to another) (ARGUMENTS:) (% ofile - name of existing library file) (% nfile - name of existing library file) (% entries - names of entries to be copied) (DESCRIPTION: copies the entries from ofile to nfile.)))
(DEFINE COPYFILE (F F1 L) (FileOp F () (LAMBDA (F) (COND ((SETQ F1 (OpenFile (FileName F1))) (COND ((NULL (READ@ 40)) (INPUT F) (PRINT@ 40 (READ@ 40)))) (INPUT F) (PROG1 (FileApply F L (LAMBDA (X) (COND ((DocLoc F X) (SFP F1 (Eof F1)) (PRIN1 (QUOTE %;)) (PRINT (READ@ (DocLoc F X))) (Update F1 X (ADD1 (Eof F1)) (GFP F1)) (PRINT (READ@ (ValueLoc F X))) (PRINT (READ)) (Eof F1 (GFP F1)))))) (CloseFile F1 T T)))))))
(QUOTE ())
;(QUOTE (((LISTFILE file ofile entries) - list the entries of a file) (DESCRIPTION: Prints the -entries- from -file- on -ofile-.) (-ofile- can be a previously non existent disk file or a logical) (output device. Each entry is printed with its documentation first,) (its function definiton second, and, if present, its property) (list last.) (EXAMPLES:) (% (LISTFILE (QUOTE EDIT) (QUOTE EDIT.PRN) T) - list the whole EDIT file to EDIT.PRN) (% (LISTFILE (QUOTE FILE) (QUOTE CON:) (QUOTE LISTFILE)) - list this entry on the console)))
;(QUOTE (((FileMac file entries mode action) - file operation macro) (ARGUMENTS:) (% file - name of library file) (% entries - names of entries to operate on. T means all on file.) (% mode - () = read only, T = modify file) (% action - an expression to be applied to each of the entries)))
(MACRO FileMac FORM (LIST FileOp (CADR FORM) (NTH FORM 4) (LIST (QUOTE LAMBDA) (QUOTE (F)) (LIST FileApply (QUOTE F) (CADDR FORM) (LIST (QUOTE LAMBDA) (QUOTE (X)) (NTH FORM 5))))))
(QUOTE ())
;(QUOTE (((FileOp file mode action) - perform a file operatin) (DESCRIPTION: opens file, applies action to file, closes file. mode) (specifies whether the file%'s directory is updated or not.)))
;(QUOTE (((FileApply file entries action)) (DESCRIPTION: Applies the function %'action%' each element of the) (entries list.)))
(DEFINE FileApply (F L Op) (MAPCONS (LAMBDA (X) (IF (Op X) X (LIST X))) (COND ((EQ L T) (Entrylist F)) ((ATOM L) (LIST L)) (T L))))
(QUOTE ())
;(QUOTE (((OPENFILE F) - open a library file) (DESCRIPTION: Opens the file, checks for the proper header, reads the) (file%'s directory and returns the file name or () if the) (file was not a standard iLISP library file.)))
(DEFINE OpenFile (F) (COND (F (INPUT (OPEN F (QUOTE U))) (OUTPUT (CAR (ERRORSET T (COND ((EQ (QUOTE iLISP-Library-File) (CADR (READ))) (Directory F (CADR (READ@ (Eof F (READ))))) F) (T (CLOSE F) ()))))) (OUTPUT))))
(QUOTE ())
;(QUOTE (((CLOSEFILE F mode value) - close a library file) (DESCRIPTION: If mode is NIL, CLOSEFILE just performs a standard CLOSE.) (If mode is not NIL, CLOSEFILE writes the file%'s directory back to the) (end of the file and updates the necessary pointers and then CLOSEs) (the file.) (% The value of CLOSEFILE is always -value-.)))
;(QUOTE (((FileName F) - return a full file name) (DESCRIPTION: Filename returns the full CP/M file name of a given file,) (including the disk prefix and type suffix.)))
(DEFINE FileName (F) (CAR (FILDIR F)))
(QUOTE ())
;(QUOTE (((PPDEF F) - prettyprint a function defining expression) (DESCRIPTION: Prettyprints the result of a call on DEFEXP.)))
(DEFINE PPDEF (FN) (PP (DEFEXP FN)))
(QUOTE ())
;(QUOTE (((DocPrint X) - print the documentation) (DESCRIPTION: Prints a documentation list in a nice readable fashion,) (with preceeding semicolons, and using PRIN1.)))
;(QUOTE (((EntryList F) - find the entries on file F) (DESCRIPTION: returns a list of the entry names on the opened file F by) (extracting them from the directory.)))
(DEFINE Entrylist (F) (MAPCONSN ATOM (Directory F)))
(QUOTE ())
;(QUOTE (((Update F X DA VA) - update a directory entry) (DESCRIPTION: Replaces the directory entry for X on open file F with one) (which locates the data (value and property list) at position VA and the) (documentation at position DA.)))
(DEFINE Update (F X DA VA) (Directory F (NCONC (LIST X (LIST VA DA)) (LISTREM (Directory F) X))))
(QUOTE ())
;(QUOTE (((ValueLoc F X) - find location of value entry for X on F) (DESCRIPTION: Just looks it up in the directory.)))