home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / f / ilisp-2.lbr / FILE.LZP / FILE.LSP
Encoding:
Text File  |  1993-10-26  |  9.8 KB  |  79 lines

  1. (QUOTE iLISP-Library-File)
  2. 9370
  3.       (QUOTE %(C%)% Copyright% by% Computing% Insights,% 1983)
  4.                             
  5. ;(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.)))
  6. (DEFINE INFILE (F L) (FileMac F L () (COND ((ValueLoc F X) (EVAL (READ@ (ValueLoc F X))) (SETPL X (EVAL (READ))) X))))
  7. (QUOTE ())
  8. ;(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.)))
  9. (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))))))
  10. (QUOTE ())
  11. ;(QUOTE (((DIRFILE file) - return a list of file entries) (ARGUMENT: file - a library file name) (DESCRIPTION: returns a list of the entries on file)))
  12. (DEFINE DIRFILE (F) (FileOp F () Entrylist))
  13. (QUOTE ())
  14. ;(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.)))
  15. (DEFINE PURGEFILE (F L) (FileMac F (IF (EQ L T) () L) T (PROGN (Directory F (LISTREM (Directory F) X)) X)))
  16. (QUOTE ())
  17. ;(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)))
  18. (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))))))
  19. (QUOTE ())
  20. ;(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.)))
  21. (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))))))
  22. (QUOTE ())
  23. ;(QUOTE (((PACKFILE file) - squeeze a library file) (DESCRIPTION: Eliminates wasted or inaccessible space from a) (%     library file.)))
  24. (DEFINE PACKFILE (F) (PROGN (ERASE (QUOTE %$%$%$%$%$%$%$%$)) (INITFILE (QUOTE %$%$%$%$%$%$%$%$)) (COPYFILE F (QUOTE %$%$%$%$%$%$%$%$) T) (ERASE F) (RENAME F (QUOTE %$%$%$%$%$%$%$%$))))
  25. (QUOTE ())
  26. ;(QUOTE (((INITFILE file) - create a new library file) (DESCRIPTION: creates a new library file with no entries.)))
  27. (DEFINE INITFILE (F) (LETSYS ((OUTPUT (OPEN F (QUOTE W)))) (PRINT (QUOTE (QUOTE iLISP-Library-File))) (PRINT 128) (SPACES 40) (PRINT@ 40 ()) (SFP F 126) (TERPRI) (PRINT (QUOTE (QUOTE ()))) (CLOSE F)))
  28. (QUOTE ())
  29. ;(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.)))
  30. (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)))))))
  31. (QUOTE ())
  32. ;(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)))
  33. (DEFINE LISTFILE (F LF L) (FileOp F () (LAMBDA (F) (LETSYS ((OUTPUT (OPEN LF (QUOTE W))) (LINELENGTH 80)) (TERPRI) (OUTB 12) (PRIN1 (QUOTE FILE:% )) (PRINT F) (COND ((READ@ 40) => (LAMBDA (X) (PRIN1 (CADR X))))) (TERPRI) (FileApply F L (LAMBDA (X) (COND ((DocLoc F X) (TERPRI) (DocPrint (CADR (READ@ (DocLoc F X)))) (TERPRI) (PP (READ@ (ValueLoc F X))) (TERPRI) (LET ((PL (CADR (READ)))) (IF PL (PP (LIST (QUOTE SETPL) (LIST (QUOTE QUOTE) X) PL)))) (TERPRI) X)))) (CLOSE LF)))))
  34. (QUOTE ())
  35. ;(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)))
  36. (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))))))
  37. (QUOTE ())
  38. ;(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.)))
  39. (DEFINE FileOp (File Mode Op) (LETSYS ((LINELENGTH 0) (INPUT) (OUTPUT)) (SETQ File (FileName File)) (IF (OpenFile File) (CloseFile File Mode (CAR (ERRORSET T (Op File)))))))
  40. (QUOTE ())
  41. ;(QUOTE (((FileApply file entries action)) (DESCRIPTION: Applies the function %'action%' each element of the) (entries list.)))
  42. (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))))
  43. (QUOTE ())
  44. ;(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.)))
  45. (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))))
  46. (QUOTE ())
  47. ;(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-.)))
  48. (DEFINE CloseFile (F M VAL) (PROGN (COND (M (PRINT@ (Eof F) (LIST (QUOTE QUOTE) (Directory F))) (PRINT (PACK (QUOTE (26 26 26 26)))) (PRINT@ 0 (QUOTE (QUOTE iLISP-Library-File))) (PRINT (Eof F)))) (SETPL (CLOSE F) ()) VAL))
  49. (QUOTE ())
  50. ;(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.)))
  51. (DEFINE FileName (F) (CAR (FILDIR F)))
  52. (QUOTE ())
  53. ;(QUOTE (((PPDEF F) - prettyprint a function defining expression) (DESCRIPTION: Prettyprints the result of a call on DEFEXP.)))
  54. (DEFINE PPDEF (FN) (PP (DEFEXP FN)))
  55. (QUOTE ())
  56. ;(QUOTE (((DocPrint X) - print the documentation) (DESCRIPTION: Prints a documentation list in a nice readable fashion,) (with preceeding semicolons, and using PRIN1.)))
  57. (DEFINE DocPrint (X) (MAPNIL (LAMBDA (X) (PROGN (PRIN1 (QUOTE %;% )) (MAPNIL (LAMBDA (X) (PROGN (PRIN1 X) (SPACES 1))) X) (TERPRI))) X))
  58. (QUOTE ())
  59. ;(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.)))
  60. (DEFINE Entrylist (F) (MAPCONSN ATOM (Directory F)))
  61. (QUOTE ())
  62. ;(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.)))
  63. (DEFINE Update (F X DA VA) (Directory F (NCONC (LIST X (LIST VA DA)) (LISTREM (Directory F) X))))
  64. (QUOTE ())
  65. ;(QUOTE (((ValueLoc F X) - find location of value entry for X on F) (DESCRIPTION: Just looks it up in the directory.)))
  66. (DEFINE ValueLoc (F X) (CAR (LISTGET (Directory F) X)))
  67. (QUOTE ())
  68. ;(QUOTE (((DocLoc F X) - find the location of the documentation of X on file F) (DESCRIPTION: Just looks it up in the directory.)))
  69. (DEFINE DocLoc (F X) (CADR (LISTGET (Directory F) X)))
  70. (QUOTE ())
  71. ;(QUOTE (((Eof X) - get/set the Eof indicator on the property list of X)))
  72. (MACRO Eof FORM (PROPERTY FORM))
  73. (QUOTE ())
  74. ;(QUOTE (((Directory X) - get/set the Directory indicator on the property list of X)))
  75. (MACRO Directory FORM (PROPERTY FORM))
  76. (QUOTE ())
  77. (QUOTE (Directory (9318 9231) Eof (9184 9109) DocLoc (9040 8908) ValueLoc (8838 8718) Update (8606 8367) Entrylist (8300 8133) DocPrint (7982 7812) PPDEF (7761 7633) FileName (7580 7410) CloseFile (7172 6837) OpenFile (6608 6384) FileApply (6238 6110) FileOp (5922 5727) FileMac (5532 5238) LISTFILE (4745 4211) COPYFILE (3782 3499) INITFILE (3284 3168) PACKFILE (2969 2834) DOCFILE (2580 2330) EDITFILE (2105 1884) PURGEFILE (1762 1504) DIRFILE (1445 1293) OUTFILE (875 537) INFILE (404 129)))
  78. 
  79.