[comp.os.vms] EDITLIB/LIBEDIT

carl@CITHEX.CALTECH.EDU (Carl J Lydick) (07/05/88)

 > I have an idea floating around in my head which  I'd  like  to  bounce  off
 > fellow INFO-VAXers ...  it's for a program which could be called EDITLIB or
 > LIBEDIT (ex SCOPErs or NOS/BErs will recognise the terms  ...).   Basically
 > it  involves calls to the librarian and callable-editor routines:  the idea
 > is that a user types
 > 
 >         $ EDIT/LIB <libname> {/HELP|TEXT} <modulename>
 > 
 > and the program automatically yanks the module out of the  library  into  a
 > scratch  file, threads the callable-editor routine, and replaces the module
 > when the edit is complete.  Obviously it's only applicable to text and help
 > libraries, at least until there are callable binary editors.
 > 
 > Now, the questions are:  is it worth-while ?  Has it been done before ?  Is
 > it already in V5 ?

How about the following DCL procedure?  It even lets use your favorite editor,
binary editors included.
$!**************************** EDITLIB.COM begins ******************************
$!	EDITLIB.COM -- EDIT a module in a help or text LIBrary
$	ON CONTROL_Y THEN GOTO DELE
$ LBL1:	IF P1 .NES. "" THEN GOTO LBL2
$	READ/PROMPT="Library name: "/ERR=LBL1 SYS$COMMAND P1
$	GOTO LBL1
$ LBL2:	IF P2 .NES. "" THEN GOTO LBL3
$	READ/PROMPT="Library type: "/ERR=LBL2 SYS$COMMAND P2
$	GOTO LBL2
$ LBL3:	IF P3 .NES. "" THEN GOTO LBL4
$	READ/PROMPT="Module name: "/ERR=LBL3 SYS$COMMAND P3
$	GOTO LBL3
$ LBL4:	IF F$EXTRACT(0,1,P2) .NES. "/" THEN P2 = "/" + P2
$	LIBRARY 'P1' 'P2' /EXTRACT='P3'/OUTPUT=SYS$SCRATCH:EDITLIB.TMP
$ EDIT:	EDIT SYS$SCRATCH:EDITLIB.TMP
$ TEST:	READ/PROMPT="Quit, Replace_module, or Edit [Q/R/E]: " SYS$COMMAND P4
$	P4 = F$EXTRACT(0, 1, F$EDIT(P4, "UPCASE"))
$	IF P4 .EQS. "Q" THEN GOTO DELE
$	IF P4 .EQS. "E" THEN GOTO EDIT
$	IF P4 .NES. "R" THEN GOTO TEST
$	LIBRARY 'P1' 'P2' /MODULE='P3' SYS$SCRATCH:EDITLIB.TMP
$ DELE:	DELETE SYS$SCRATCH:EDITLIB.TMP;*
$!***************************** EDITLIB.COM ends *******************************

 > Could it be extended to provide a simple alternative to CMS/MMS,  allowing,
 > for example, an easy edit/compile/link/run system in which only the modules
 > changed are re-compiled ?  Any thoughts/comments ?

Most of the difficulty in writing something like MAKE is involved  in  parsing
the dependencies.  Getting and comparing modification dates is pretty trivial.
For example, consider the files listed in the following directory output:

	Directory $USERS:[CARL.SOURCE]

	FORCEX.C;3            3-MAR-1987 13:37
	FORCEX.OBJ;1          9-FEB-1987 14:16

	Total of 2 files.

To compare the modification dates, we just:
	$ C_REV_DATE = F$CVTIME(F$FILE("$USERS:[CARL.SOURCE]FORCEX.C","RDT"))
	$ O_REV_DATE = F$CVTIME(F$FILE("$USERS:[CARL.SOURCE]FORCEX.OBJ","RDT"))
	$ WRITE SYS$OUTPUT F$FAO("!_C:!_!AS!/!_O:!_!AS", C_REV_DATE, O_REV_DATE)
	$ IF C_REV_DATE .GTS. O_REV_DATE THEN WRITE SYS$OUTPUT -
		"THE MODULE NEEDS TO BE RECOMPILED"
	$ IF C_REV_DATE .LES. O_REV_DATE THEN WRITE SYS$OUTPUT -
		"THE MODULE IS UP TO DATE"
Which results in:
		C:	1987-03-03 13:37:40.56
		O:	1987-02-09 14:16:24.57
	THE MODULE NEEDS TO BE RECOMPILED

The difficulty lies in figuring out that it was the revision  dates  of  those
two  files  that  needed  to  be compared, and then deciding what to do if the
object module is out of date.  So I think the answer  is  no,  something  that
lets  you  easily  edit  libraries  can't  be  extended  to  provide  a SIMPLE
alternative to CMS/MMS.

By the way, please pardon the two-month delay  between  your  posting  and  my
reply; the message just arrived here today.

nagy%warner.hepnet@LBL.GOV (Frank J. Nagy, VAX Wizard & Guru) (07/06/88)

> I have an idea floating around in my head which I'd like to bounce off fellow
> INFO-VAXers ... it's for a program which could be called EDITLIB or LIBEDIT
> (ex SCOPErs or NOS/BErs will recognise the terms ...).
     
Here are a couple of command procedures I use to do this.  EDITHELP allows
me to extract, edit and replace an entry in a HELP library.  TLBEDIT allows
me to manipulate and edit text library entries.

= Frank J. Nagy   "VAX Guru & Wizard"
= Fermilab Research Division EED/Controls
= HEPNET: WARNER::NAGY (43198::NAGY) or FNAL::NAGY (43009::NAGY)
= BitNet: NAGY@FNAL
= USnail: Fermilab POB 500 MS/220 Batavia, IL 60510

....................... Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.01 01-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by NAGY
$! on Wednesday 6-JUL-1988 08:26:38.28
$!
$! It contains the following 2 files:
$! EDITHELP.COM TLBEDIT.COM
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="EDITHELP.COM"
$ Check_Sum_is=889209455
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$ verify = 'F$VERIFY(0)'
X$!.. EDITHELP.COM`009`009Edit a module in a help library
X$L1$:
X$ IF p1 .EQS. "" THEN $ INQUIRE  p1  "Help module"
X$ IF p1 .EQS. "" THEN $ GOTO L1$
X$ deflibe = "SYS$HELP:FERMIHELP.HLB"
X$ IF F$SEARCH( deflibe) .EQS. "" THEN deflibe = "RDCS$HELP:FERMIHELP.HLB"
X$ p2 = F$PARSE( p2, deflibe + ";0")`009!Help library specification
X$ deletion = 0`009`009`009`009!/NODELETE assumed
X$ lse = 0`009`009`009`009! no /LSE assumed
X$ qual = F$ELEMENT( 1, "/", p1)
X$ IF qual .EQS. "/" THEN $ GOTO EXTRACTOR
X$ IF F$EXTRACT(0,3,qual) .EQS. "DEL" THEN deletion = 1`009!/DELETE found
X$ IF F$EXTRACT(0,3,qual) .EQS. "LSE" THEN lse = 1`009!/LSE found
X$ IF .NOT. (deletion .OR. lse) THEN $ GOTO BAD_QUALIFIER
X$ p1 = F$ELEMENT( 0, "/", p1)
X$ qual = F$ELEMENT( 1, "/", qual)`009!Try for 2nd qualifier
X$ IF qual .EQS. "/" THEN $ GOTO EXTRACTOR
X$ name = ""
X$ IF F$EXTRACT(0,3,qual) .EQS. "DEL" THEN name = "deletion" `009!/DELETE found
X$ IF F$EXTRACT(0,3,qual) .EQS. "LSE" THEN name = "lse"`009`009!/LSE found
X$ IF name .EQS. "" THEN $ GOTO BAD_QUALIFIER
X$ 'name' = 1
X$EXTRACTOR:
X$ IF p1 .EQS. ".NEW" THEN $ GOTO EDITOR`009!".NEW" means adding new module
X$ ON ERROR THEN $ GOTO GET_OUT`009`009!Extract help module to temp file
X$ LIBRARY/HELP/EXTRACT='p1'/OUTPUT=EDITHELP.TMP  'p2'
X$ IF deletion THEN $ LIBRARY/HELP/DELETE='p1'  'p2'
X$EDITOR:
X$ ON CONTROL_Y THEN $ GOTO KILL_FILE
X$ ON ERROR THEN $ GOTO KILL_FILE
X$ ee := EDIT/EDT`009`009`009`009!Default to EDT editor
X$ IF F$TYPE(EDT) .NES. "" THEN ee = EDT`009`009!If EDT symbol defined...
X$ IF F$TYPE(EDTX) .NES. "" THEN ee = EDTX`009!If EDTX symbol defined...
X$ IF lse THEN ee := LSEDIT`009`009`009!Use default LSE command
X$ IF lse .AND. F$TYPE(LSEDIT) THEN ee = LSEDIT`009!Use redefined LSE command
X$ DEFINE/USER_MODE  SYS$INPUT  SYS$COMMAND:`009!Now edit the temp file
X$ ee EDITHELP.TMP
X$ old_privs = F$SETPRV( "SYSPRV")`009!Restore the help module
X$ ON ERROR THEN $ GOTO PRESERVE_FILE
X$ LIBRARY/HELP/REPLACE/LOG  'p2'  EDITHELP.TMP
X$ old_privs = F$SETPRV( old_privs)
X$KILL_FILE:
X$ DELETE  EDITHELP.TMP;*
X$GET_OUT:
X$ EXIT`009F$VERIFY(verify).OR.1
X$PRESERVE_FILE:
X$ old_privs = F$SETPRV( old_privs)
X$ WRITE SYS$OUTPUT "%EDITHELP-I-PRESERVES, edits saved in file EDITHELP.TMP"
X$ EXIT`009F$VERIFY(verify).OR.1
X$BAD_QUALIFIER:
X$ WRITE SYS$OUTPUT "%EDITHELP-F-BADQUAL, qualifier was not /DELete or /LSE"
X$ EXIT`009F$VERIFY(verify).OR.1
X$!=============================================================================
X$!+ EDITHELP
X$! Procedure to extract a help entry from a library, enter the EDT editor
X$! to update the entry and replace in the help library when the edits are
X$! completed.  Format:
X$!
X$!`009@FERMI$UTIL:EDITHELP  help-entry[/DELETE][/LSE]  [library]
X$!
X$! If the /DELETE qualifier is used on the help entry name, the module
X$! will be deleted from the library after being extracted under the
X$! assumption that the module name will be changed in the edit session.
X$! If /LSE is used, then the Language Sensitive Editor is used.
X$!
X$! If a library is not specified, SYS$HELP:FERMIHELP.HLB is assumed (if
X$! FERMIHELP.HLB is not in SYS$HELP, then RDCS$HELP:FERMIHELP.HLB is used).
X$! If a library name is given but no device or directory, SYS$HELP: is
X$! used as a default.
X$!
X$! If the help-entry is ".NEW" then no entry will be extracted from the
X$! library but EDT will be entered to create a new help entry or entries.
X$!-
X$!=============================================================================
X$! Modifications:
X$!  16-Oct-84`009FJN`009Created to eliminate need for separate help sources
X$!  05-Jun-85`009FJN`009Compacting/moving comments
X$!  17-Jun-85`009FJN`009Change means of extracting /DELETE to use VMS V4
X$!`009`009`009lexical functions; add test for .NEW flag
X$!  25-Oct-85`009FJN`009Preserve EDITHELP.TMP file if problem inserting it
X$!  05-Nov-85`009FJN`009Change default to CMN$HELP
X$!  11-Jul-86`009FJN`009If EDT or EDTX symbols defined, use then to invoke the
X$!`009`009`009editor rather than EDT.
X$!  21-Apr-87`009FJN`009Added /LSE qualifier; allow for assuming FERMIHELP from
X$!`009`009`009RDCS$HELP
$ GoSub Convert_File
$ File_is="TLBEDIT.COM"
$ Check_Sum_is=543441187
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$ verify = 'F$VERIFY(0)'
X$!.. TLBEDIT.COM`009`009`009Edit/manipulate text library modules
X$!.. Description and history at end of file
X$ TELL := WRITE SYS$OUTPUT
X$ VT := $FERMI$EXE:T
X$ ee := EDIT/EDT`009`009`009`009!Default to EDT editor
X$ IF F$TYPE(EDT) .NES. "" THEN ee = EDT`009`009!If EDT symbol defined...
X$ IF F$TYPE(EDTX) .NES. "" THEN ee = EDTX`009!If EDTX symbol defined...
X$L1$:
X$ IF p1 .EQS. "" THEN $ INQUIRE  p1  "Text library"
X$ IF p1 .EQS. "" THEN $ GOTO L1$
X$ read_only := FALSE`009`009!Remove /READONLY qualifier if used
X$ qual = F$ELEMENT( 1, "/", p1)
X$ IF qual .EQS. "/" THEN $ GOTO SKIP_EXTRACTING
X$ p1 = F$ELEMENT( 0, "/", p1)
X$ IF p1 .EQS. "" THEN $ GOTO L1$
X$ read_only := TRUE
V$ IF qual .EQS. F$EXTRACT(0,F$LENGTH(qual),"READONLY") THEN $ GOTO SKIP_EXTRACT
XING
X$ TELL "%TLBEDIT-F-BADQUAL, unknown qualifier used on library specification"
X$ EXIT`009F$VERIFY(verify).OR.1
X$NO_LIBRARY:
X$ TELL "%TLBEDIT-F-NOLIBFILE, no such file found"
X$ EXIT`009F$VERIFY(verify).OR.1
X$SKIP_EXTRACTING:
X$ p1 = F$PARSE( p1, "SYS$DISK:[].TLB;0")`009!Get text library spec
X$ IF F$SEARCH(p1) .EQS. "" THEN $ GOTO NO_LIBRARY
X$ message_settings = F$ENVIRONMENT( "MESSAGE")
X$ SET MESSAGE /NOFACILITY /IDENTIFICATION /NOSEVERITY /TEXT
X$!
X$! Main loop to input and decode the commands and dispatch to the processing
X$! routines.
X$!
X$ commands = "/COMPRESS/COPY/CREATE/DELETE/DIRECTORY/EDIT/EXIT/LIST"
X$ commands = commands + "/RENAME/TYPE/VIEW/EVIEW/MEDIT/XTRACT/HELP/"
X$ len_commands = F$LENGTH(commands)
X$MAIN_LOOP:
X$ ON ERROR THEN $ GOTO FUNCTION_EXIT
X$ ON CONTROL_Y THEN $ GOTO FUNCTION_EXIT
X$ INQUIRE/NOPUNCTUATION  cline  "TED> "
X$ cline = F$EDIT( cline, "COMPRESS,UPCASE,UNCOMMENT,TRIM")
X$ IF cline .EQS. "?" THEN $ GOTO DISPLAY_FUNCTION_MENU
X$ command = F$ELEMENT( 0, " ", cline)
X$ IF F$LENGTH(command) .LT. 2 THEN $ GOTO CERROR_LEN
X$ IF command .EQS. "CO" THEN $ GOTO CERROR_LEN
X$ m = F$LOCATE( "/" + command, commands)
X$ IF m .EQ. len_commands THEN $ GOTO CERROR_UNK
X$ command = F$ELEMENT( 0, "/", F$EXTRACT(m, len_commands, commands) - "/")
X$ arg1 = F$ELEMENT( 1, " ", cline)
X$ IF arg1 .EQS. " " THEN arg1 = ""
X$ arg2 = F$ELEMENT( 2, " ", cline)
X$ IF arg2 .EQS. " " THEN arg2 = ""
X$DISPATCH:
X$ ON ERROR THEN $ GOTO MAIN_LOOP
X$ ON CONTROL_Y THEN $ GOTO MAIN_LOOP
X$ GOTO FUNCTION_'command'
X$CERROR_LEN:
X$ TELL "%TLBEDIT-E-TOOSHORT, command verb too short"
X$ GOTO MAIN_LOOP
X$CERROR_UNK:
X$ TELL "%TLBEDIT-E-UNKCMD, unknown command verb"
X$ GOTO MAIN_LOOP
X$DISPLAY_FUNCTION_MENU:
X$ TYPE SYS$INPUT:
X
X Current TLBEDIT commands are:
X
X`009COMPRESS`009COPY`009CREATE`009DELETE`009DIRECTORY`009EDIT
X`009EVIEW`009EXIT`009HELP`009LIST`009MEDIT`009RENAME`009TYPE`009VIEW
X`009XTRACT
X
X$ GOTO MAIN_LOOP
X$!
X$! Here we process the various TED commands...
X$!
X$FUNCTION_COMPRESS:`009`009`009!COMPRESS
X$`009LIBRARY/TEXT/COMPRESS`009'p1'
X$`009p1x = p1 - F$PARSE( p1,,, "VERSION", "SYNTAX_ONLY")
X$`009PURGE  'p1x'
X$`009SET FILE/TRUNCATE`009'p1'
X$ GOTO MAIN_LOOP
X$FUNCTION_COPY:`009`009`009`009!COPY`009old-module`009new-module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "Old module"
X$`009IF arg2 .EQS. "" THEN $ INQUIRE  arg2  "New module"
X$`009IF (arg1 .EQS. "") .OR. (arg2 .EQS. "") THEN $ GOTO FUNCTION_COPY
X$`009LIBRARY/TEXT/EXTRACT='arg1'/OUTPUT=COPY.TMP`009'p1'
X$`009LIBRARY/LOG/TEXT/INSERT`009`009'p1'`009COPY.TMP/MODULE='arg2'
X$`009DELETE`009COPY.TMP;*
X$ GOTO MAIN_LOOP
X$FUNCTION_CREATE:`009`009`009!CREATE`009new-module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "New module"
X$`009IF arg1 .EQS. "" THEN $ GOTO FUNCTION_CREATE
X$`009DEFINE/USER_MODE  SYS$INPUT`009SYS$COMMAND:
X$`009EE  CREATE.TMP
X$`009LIBRARY/LOG/TEXT/INSERT`009`009'p1'`009CREATE.TMP/MODULE='arg1'
X$`009DELETE`009CREATE.TMP;*
X$ GOTO MAIN_LOOP
X$FUNCTION_DELETE:`009`009`009!DELETE`009module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "Module"
X$`009IF arg1 .EQS. "" THEN $ GOTO FUNCTION_DELETE
X$`009LIBRARY/LOG/TEXT/DELETE='arg1'`009'p1'
X$ GOTO MAIN_LOOP
X$FUNCTION_DIRECTORY:`009`009`009!DIRECTORY
X$`009LIBRARY/TEXT/LIST/FULL`009'p1'
X$ GOTO MAIN_LOOP
X$FUNCTION_EDIT:`009`009`009`009!EDIT`009module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "Module"
X$`009IF arg1 .EQS. "" THEN $ GOTO FUNCTION_EDIT
X$`009LIBRARY/TEXT/EXTRACT='arg1'/OUTPUT=EDIT.TMP`009'p1'
X$`009DEFINE/USER_MODE  SYS$INPUT`009SYS$COMMAND:
X$`009EE  EDIT.TMP
X$`009LIBRARY/LOG/TEXT/REPLACE`009'p1'`009EDIT.TMP/MODULE='arg1'
X$`009DELETE`009EDIT.TMP;*
X$ GOTO MAIN_LOOP
X$FUNCTION_HELP:`009`009`009`009!HELP
X$`009DEFINE /USER_MODE`009SYS$INPUT`009SYS$COMMAND:
X$`009HELP /LIBRARY=RDCS$HELP:FERMIHELP`009TLBEDIT
X$ GOTO MAIN_LOOP
X$FUNCTION_LIST:`009`009`009`009!LIST
X$`009LIBRARY/TEXT/LIST`009'p1'
X$ GOTO MAIN_LOOP
X$FUNCTION_MEDIT:`009`009`009!MEDIT
X$`009LIBRARY/TEXT/LIST=MODULES.LIS`009'p1'
X$`009skipheader = 1
X$`009OPEN /READ`009MDIRE`009MODULES.LIS
X$`009CREATE /FDL=SYS$INPUT`009MASSEDIT.TMP
X`009`009RECORD
X`009`009`009CARRIAGE_CONTROL`009CARRIAGE_RETURN
X`009`009`009FORMAT`009`009`009VARIABLE
X$`009OPEN /APPEND`009MEX`009MASSEDIT.TMP
X$`009MEDIT_XLOOP:
X$`009`009READ /END_OF_INFORMATION=MEDIT_XDONE`009MDIRE`009line
X$`009`009IF line .EQS. "" THEN $ GOTO MEDIT_XSKPX
X$`009`009IF skipheader THEN $ GOTO MEDIT_XLOOP
X$`009`009WRITE`009MEX`009"\module=",line
X$`009`009LIBRARY/TEXT/EXTRACT='line'/OUTPUT=M1.TMP`009'p1'
X$`009`009APPEND`009M1.TMP`009MEX:
X$`009`009WRITE`009MEX`009"\eom"
X$`009GOTO MEDIT_XLOOP
X$`009MEDIT_XSKPX:`009`009`009!End of listing header
X$`009`009skipheader = 0`009`009!Now just a list of modules
X$`009GOTO MEDIT_XLOOP
X$`009MEDIT_XDONE:
X$`009CLOSE`009MDIRE
X$`009DELETE`009MODULES.LIS;*
X$`009CLOSE`009MEX
X$`009DELETE`009M1.TMP;*
X$`009DEFINE/USER_MODE  SYS$INPUT`009SYS$COMMAND:
X$`009EE  MASSEDIT.TMP
X$`009OPEN /READ`009MEX`009MASSEDIT.TMP
X$`009MEDIT_RLOOP:
X$`009`009READ /END_OF_INFORMATION=MEDIT_RDONE`009MEX`009line
X$`009`009IF line .EQS. "\eom" THEN $ GOTO MEDIT_RLOOP
X$`009`009IF F$ELEMENT( 0, "=", line) .NES. "\module" THEN $ GOTO MED_ERR1
X$`009`009arg1 = F$ELEMENT( 1, "=", line)
X$`009`009CREATE /FDL=SYS$INPUT`009M1.TMP
X`009`009`009RECORD
X`009`009`009`009CARRIAGE_CONTROL`009CARRIAGE_RETURN
X`009`009`009`009FORMAT`009`009`009VARIABLE
X$`009`009OPEN /APPEND`009MDC`009M1.TMP
X$`009`009MEDIT_MLOOP:
X$`009`009`009READ`009MEX`009line
X$`009`009`009IF line .EQS. "\eom" THEN $ GOTO MEDIT_MDONE
X$`009`009`009WRITE`009MDC`009line
X$`009`009GOTO MEDIT_MLOOP
X$`009`009MEDIT_MDONE:
X$`009`009CLOSE`009MDC
X$`009`009LIBRARY/LOG/TEXT/REPLACE`009'p1'`009M1.TMP/MODULE='arg1'
X$`009GOTO MEDIT_RLOOP
X$`009MEDIT_RDONE:
X$`009CLOSE`009MEX
X$`009DELETE`009MASSEDIT.TMP;*
X$`009DELETE`009M1.TMP;*
X$ GOTO MAIN_LOOP
X$MED_ERR1:
X$`009CLOSE`009MEX
X$`009DELETE`009MASSEDIT.TMP;*
X$`009DELETE`009M1.TMP;*
X$`009WRITE SYS$OUTPUT "%TLBEDIT-E-MASEDFFE, error in output file format"
X$ GOTO MAIN_LOOP
X$FUNCTION_RENAME:`009`009`009!RENAME`009old-module`009new-module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "Module"
X$`009IF arg2 .EQS. "" THEN $ INQUIRE  arg2  "New name"
X$`009IF (arg1 .EQS. "") .OR. (arg2 .EQS. "") THEN $ GOTO FUNCTION_RENAME
X$`009LIBRARY/TEXT/EXTRACT='arg1'/OUTPUT=RENAME.TMP`009'p1'
X$`009LIBRARY/LOG/TEXT/INSERT`009`009'p1'`009RENAME.TMP/MODULE='arg2'
X$`009DELETE`009RENAME.TMP;*
X$`009LIBRARY/LOG/TEXT/DELETE='arg1'`009'p1'
X$ GOTO MAIN_LOOP
X$FUNCTION_TYPE:`009`009`009`009!TYPE`009module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "Module"
X$`009IF arg1 .EQS. "" THEN $ GOTO FUNCTION_TYPE
X$`009LIBRARY/TEXT/EXTRACT='arg1'/OUTPUT=SYS$OUTPUT`009'p1'
X$ GOTO MAIN_LOOP
X$FUNCTION_VIEW:`009`009`009`009!VIEW`009module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "Module"
X$`009IF arg1 .EQS. "" THEN $ GOTO FUNCTION_VIEW
X$`009LIBRARY/TEXT/EXTRACT='arg1'/OUTPUT=VIEW.TMP`009'p1'
X$`009DEFINE/USER_MODE  SYS$INPUT`009SYS$COMMAND:
X$`009VT  VIEW.TMP
X$`009DELETE`009VIEW.TMP;*
X$ GOTO MAIN_LOOP
X$FUNCTION_EVIEW:`009`009`009!EVIEW`009module
X$`009IF arg1 .EQS. "" THEN $ INQUIRE  arg1  "Module"
X$`009IF arg1 .EQS. "" THEN $ GOTO FUNCTION_EVIEW
X$`009LIBRARY/TEXT/EXTRACT='arg1'/OUTPUT=EVIEW.TMP`009'p1'
X$`009DEFINE/USER_MODE  SYS$INPUT`009SYS$COMMAND:
X$`009EE /READ_ONLY  EVIEW.TMP
X$`009DELETE`009EVIEW.TMP;*
X$ GOTO MAIN_LOOP
X$FUNCTION_XTRACT:`009`009`009!XTRACT
X$`009IF arg1 .EQS. "" THEN arg1 = "TXT"
X$`009arg1 = arg1 - "."
X$`009LIBRARY/TEXT/LIST=MODULES.LIS`009'p1'
X$`009skipheader = 1
X$`009OPEN /READ`009XDIRE`009MODULES.LIS
X$`009XTRACT_XLOOP:
X$`009`009READ /END_OF_INFORMATION=XTRACT_XDONE`009XDIRE`009line
X$`009`009IF line .EQS. "" THEN $ GOTO XTRACT_XSKPX
X$`009`009IF skipheader THEN $ GOTO XTRACT_XLOOP
X$`009`009LIBRARY/TEXT/LOG/EXTRACT='line'/OUTPUT='line'.'arg1'`009'p1'
X$`009GOTO XTRACT_XLOOP
X$`009XTRACT_XSKPX:`009`009`009!End of listing header
X$`009`009skipheader = 0`009`009!Now just a list of modules
X$`009GOTO XTRACT_XLOOP
X$`009XTRACT_XDONE:
X$`009CLOSE`009XDIRE
X$`009PURGE`009*.'arg1'
X$`009DELETE`009MODULES.LIS;*
X$ GOTO MAIN_LOOP
X$!
X$FUNCTION_EXIT:
X$ SET NOON
X$ SET MESSAGE /NOFACILITY /NOIDENTIFICATION /NOSEVERITY /NOTEXT
X$ DELETE  *.TMP;*
X$ SET MESSAGE'message_settings'
X$ EXIT`009F$VERIFY(verify).OR.1
X$!=============================================================================
X$!+ TLBEDIT
X$! This procedure provides an interactive interface to manipulate and edit
X$! modules of a text library.  Format:
X$!
X$!`009@FERMI$UTIL:TLBEDIT  text-library[/READONLY]
X$!
X$! If the /READONLY qualifier is used, modules may be examined but no
X$! replacement operations or new module inserts will be done to the library.
X$! By default the library is assumed to be in the current directory with
X$! a file type of .TLB.
X$!
X$! The procedure prompts for input with "TED> ", the subtopics describe the
X$! commands the procedure recognizes.
X$!2 COMPRESS
X$! Compress the library, creating a new version and purging the old:
X$!
X$!`009TED> COMpress
X$!
X$!2 COPY
X$! Create a new module by copying the contents of an existing module:
X$!
X$!`009TED> COpy  old-module  new-module
X$!
X$!2 CREATE
X$! Create a new module:
X$!
X$!`009TED> CReate  new-module
X$!
X$! This command will enter the editor (in screen module) to enter the text
X$! of the module.  EDIT/EDT will be used unless the symbol EDT is defined.
X$! If the EDTX symbol is defined; it is used preferentially.
X$!2 DELETE
X$! Delete a module:
X$!
X$!`009TED> DElete  module
X$!
X$!2 DIRECTORY
X$! Provide a "directory" of the modules in the text library:
X$!
X$!`009TED> DIrectory
X$!
X$!2 EDIT
X$! Edit an existing module:
X$!
X$!`009TED> EDit  module
X$!
X$! The module will be extracted from the library to a temporary edit
X$! file and replaced after the exit is done.
X$!
X$! EDIT/EDT will be used unless the symbol EDT is defined.  
X$! If the EDTX symbol is defined; it is used preferentially.
X$!2 EVIEW
X$! Examine the contents of a module using the editor in read-only
X$! mode:
X$!
X$!`009TED> EView  module
X$!
X$! EDIT/EDT will be used unless the symbol EDT is defined.  
X$! If the EDTX symbol is defined; it is used preferentially.
X$!2 EXIT
X$! Exit the procedure:
X$!
X$!`009TED> EXit
X$!
X$!2 HELP
X$! List this information from the FERMIHELP library in RDCS$HELP:.
X$!
X$!2 LIST
X$! Provide a "directory" of the modules in the text library:
X$!
X$!`009TED> LIst
X$!
X$!2 MEdit
X$! Mass edit of many modules at once (for instance to perform one or
X$! more global search and replace operations):
X$!
X$!`009TED> MEdit
X$!
X$! All the modules are extracted and formed into a single file in which the
X$! contents of each module is preceeded by a "\module" identifier line and
X$! followed by a "\eom" terminator line:
X$!
X$!`009\module=<name>
X$!`009<contents>
X$!`009...
X$!`009\eom
X$!`009...
X$!
X$! where <name> is the module name.  During the editing process if a module's
X$! contents and identifer ("\module=") line are deleted, then the module in
X$! the library will not be changed, otherwise all those modules with
X$! identifier lines in the resulting file are replaced.
X$!2 RENAME
X$! Rename a module:
X$!
X$!`009TED> REname  old-module  new-module
X$!
X$!2 TYPE
X$! Display the contents of module:
X$!
X$!`009TED> TYpe  module
X$!
X$!2 VIEW
X$! Examine the contents of a module using the T display program:
X$!
X$!`009TED> VIew  module
X$!
X$!2 XTRACT
X$! Extract all the modules to separate files:
X$!
X$!`009TED> XTract  [type]
X$!
X$! where the argument specifies the file type of the output files for
X$! the extracted modules.  The default is ".TXT"
X$!-
X$! Modifications:
X$!  01-Jun-85`009FJN`009Created to assist in construction LA100_CONTROLS
X$!  03-Nov-85`009FJN`009Added "?" for quick help, added EVIEW command
X$!  04-Dec-85`009FJN`009Started adding MassEdit command.
X$!  21-Dec-85`009FJN`009Added XTract command.
X$!  21-Jan-86`009FJN`009Added HELP command; TLBEDIT help into FERMIHELP
X$!  11-Jul-86`009FJN`009If EDT or EDTX symbols defined, use then to invoke the
X$!`009`009`009editor rather than EDT.
X$!  26-Sep-87`009FJN`009Changed to use RDCS$HELP:FERMIHELP library
$ GoSub Convert_File
$ Exit

kenw%noah.arc.CDN@ean.ubc.ca (Ken Wallewein) (07/09/88)

  Here's another example of short-sighted solutions to a other short-sighted 
solutions.

  Libraries should have been implemented as a special kind of directory or 
device. One _should_ be able to access library files directly with existing 
facilities, such as DIRECTORY, COPY, EDIT, DELETE, etc.  You could used data 
compressed format for archiving, too.

  Certaily, there are limitations; libraries so not support all of the 
functionality of a normal ODS-2 file structure. But they could certainly be 
treated as a subset.

  Although it would be nice it the functionality was incorporated directly 
into VMS, it _could_ be done as a device driver which translated attributes.
I've seen it done - under CPM!

 /kenw
                                                                 A L B E R T A
Ken Wallewein                                                  R E S E A R C H
kenw@noah.arc.cdn                                                C O U N C I L