; Utilities for copying editable data to/from open SFS library 8/9/08 ; "NAME" A2L - copies AEDIT (or any) data from alt mem to the library ; "NAME" L2A - copies library file to altmem, space-padding for AEDIT ; These are for use with SFS/LIB2.IPL only. The CONSOLE at the end of ; IPL packages must be changed to LIBEND to properly terminate. ; ; Example usage to edit last file in the library... ; [LIB to open library] ; "NAME" L2A AEDIT - load file NAME for editing ; "NAME" LFORGET - remove last file from library ; "NAME" A2L - save edited file to library ; ; Example usage to add existing AEDIT-format file to the library... ; "FILE" LDFILE (or LDTXT if not AEDIT format) ; AEDIT and go to end of IPL file, change CONSOLE to LIBEND ; "NAME" A2L - save edited file to library ; ; These examples assume AEDIT is already in the dictionary, load ; it first if not already loaded (or make an EDIT/LIB build with ; these utilities to use when activities like these are needed). ; Do LCLOSE to actually commit the library change to disk, ; otherwise added in buffer memory only (handy for testing). ; Note... little checking to make sure alt mem is valid IPL, use wisely! ; If error occurs, 2 RUN to restart HP-IPL/OS, -SFS LIB to reopen ; library from disk if corruption occurs. ; ; NOTE - for L2A to work the LIBEND must be a line by itself with ; no surrounding spaces otherwise the end of the library file ; won't be found. This should be the case but... ; OCTAL DEFINE A2L ;uses location 150 as a temp CWA LBUF GET ADD GET #1 AND IFZ $DROP "No library" $PRINT DROP ELSE $TRIM $LEN IFZ $DROP "No name " $PRINT ELSE -1 2 52 +DO INDEX 150 #1 A>CCOPY 150 GET ;check first 41 words of data DUP 377 AND 15 SUB IFZ SWAP INC SWAP ENDIF ;inc flag if CR in low byte DUP 177400 AND 6400 SUB IFZ SWAP INC SWAP ENDIF ;inc if CR in high byte DUP 100000 AND IFNZ SWAP DEC SWAP ENDIF ;dec flag if bit 15 set IFZ DEC ENDIF ;pop value, dec flag if a zero - that should at least ;discourage accidental use from doing anything too drastic but could ;still end up with non-IPL garbage in the library and if any text ;does not end in CRLF then a corrupted library results. Tricky stuff! +LOOP IF<0 "Not text " $PRINT ELSE MS_SAVE ;save current MS vectors 2 MSUSER ;redirect MS I/O from/to alt mem LBUF GET >FILE ;redirect MS out to library LBUF GET FSA LBUF GET ADD GET DEC SEEK ;seek to end-1 ";;;FILE:" MS$OUT MS$OUT ":" MS$OUT MSCRLF ;write header CRLF "Copying altmem to library: " $PRINT #0 ;line count... print a * every 16 lines DO ;until a zero word detected in alt mem UPTR GET 150 #1 A>CCOPY ;copy current altmem word to location 150 150 GET DUP IFNZ ;if not zero... MS$IN ;input line from altmem SWAP INC SWAP OVER 17 AND IFZ 52 PCHR ENDIF ;print progress ;remove trailing spaces... DO $LEN DEC $GET 40 SUB IFZ $TAIL DROP #0 ELSE #1 ENDIF UNTIL ;leading spaces can't be removed as that breaks CREATE code MS$OUT MSCRLF ;write trimmed line to library ENDIF WHILE ;last line was non-zero, loop until all of altmem copied DROP ;line counter 200 MSBOUT ;terminate library MS_RESTORE ;restore MS vectors CRLF "Done" $PRINT CRLF ENDIF ENDIF ENDIF END ; OCTAL DEFINE L2A CWA LBUF GET ADD GET #1 AND IFZ $DROP "No library" $PRINT DROP ELSE $LEN DROP ;fail if "NAME" not specified ZAM ;clear alt memory MS_SAVE ;save MS vectors 2 MSUSER ;redirect MS I/O from/to alt memory LBUF GET DUP