gregg@a.cs.okstate.edu@mandrill.CWRU.Edu (Gregg Wonderly) (10/13/87)
$ show default $ if f$search("EXE.DIR;1") .eqs. "" then - CREATE/LOG/DIRECTORY [.EXE] $ write sys$output "Creating [.EXE]VI.COM" $ create [.EXE]VI.COM $ DECK/DOLLARS="*$*$*EOD*$*$*" $! $! VI.COM $! $! Written by Gregg Wonderly 30-OCT-1986 $! $! A command file to run VI as a subprocess to the current DCL process. $! $! Check to see if the process already exists $! $ VI = "EDIT/TPU" $! OR VI = "VI" if you are using VI.EXE $! $ TT = F$GETDVI("SYS$COMMAND","DEVNAM") - "_" - "-" - ":" $ EDIT_NAME = "Edit_" + TT $ PRIV_LIST = F$SETPRV("NOGROUP,NOWORLD") $ PID = 0 $! $ LOOP: $ MPID = F$PID(PID) $ PROC = F$GETJPI(MPID,"PRCNAM") $! $! If process is there, then go attach to it $! $ IF PROC .EQS. EDIT_NAME THEN GOTO ATTACH $ IF PID .NE. 0 THEN GOTO LOOP $! $! If we fall through, then no such process, so spawn the editor $! $ SPAWN: $ PRIV_LIST = F$SETPRV(PRIV_LIST) $ DEFINE/NOLOG SYS$INPUT SYS$COMMAND: $ T1 = F$EDIT(P2 + " " + P3 + " " + P4 + " " + P5 + " " - + P6 + " " + P7, "UPCASE,COLLAPSE") $ T1 = "''T1' ''P1'" $ DEFINE/JOB/NOLOG TPU$ATTACH_NAME "''f$getjpi("","prcnam")'" $ DEFINE/JOB/NOLOG TPU$SEARCH " " $ DEFINE/JOB/NOLOG TPU$LINE " " $ DEFINE/JOB/NOLOG TPU$OUTPUT " " $ DEFINE/JOB/NOLOG TPU$ARGS " " $ DEFINE/JOB/NOLOG TPU$NEWCMD " " $ IF ("''P8'" .EQS. "NOSPAWN") THEN GOTO NOSPAWN $ WRITE SYS$ERROR "[Spawning a new kept editor]" $ SPAWN/PROCESS="''EDIT_NAME'"/NOLOG VI 'T1' $ SUSPEND/NAME="''EDIT_NAME'" $ WRITE SYS$ERROR "[Back from edit]" $ GOTO DONE $! $! Startup the editor without spawning $! $ NOSPAWN: $ WRITE SYS$OUTPUT T1 $ DEFINE/NOLOG/JOB TPU$NOSUBPROC 1 $ VI 'T1' $ DEASSIGN/JOB TPU$NOSUBPROC $ GOTO DONE $! $! Come here if subprocess already exists. $! $ ATTACH: $! $! For the attach, we allow some parameters to be passed to the editor, $! other than the filename. Specifically, a string to search for, or $! a line number to go to. $! $ PRIV_LIST = F$SETPRV(PRIV_LIST) $ LINENO = " " $ SEARCH = " " $ OUTPUT = " " $ NEWCMD = " " $ LIST== F$EDIT ("''P1' ''P2' ''P3' ''P4' ''P5' ''P6' ''P7'", - "UPCASE,TRIM,COMPRESS") $ START = F$LOCATE ("/OUT", LIST) $ IF (START .EQ. F$LENGTH(LIST)) THEN GOTO NOOUT $ REMAIN = F$EXTRACT (START,255,LIST) $ END = F$LOCATE ("=", REMAIN) $ IF (END .NE. F$LENGTH (REMAIN)) THEN GOTO OUT_1 $ WRITE SYS$ERROR F$MESSAGE(%X38150) $ WRITE SYS$ERROR " \OUTPUT\" $ EXIT $! $ OUT_1: $ OUTPUT=F$EXTRACT(END+1,F$LOCATE(" ",REMAIN)-END-1,REMAI N) $ LIST = F$EXTRACT (0,START,LIST) + - F$EXTRACT(END+2+F$LENGTH(OUTPUT),255,RE MAIN) $! $ NOOUT: $ IF (F$EXTRACT(0,1,P1) .NES. "+") THEN GOTO NO_LINE $ IF (F$EXTRACT(1,1,P1) .NES. "/") .AND. - (F$EXTRACT(1,1,P1) .NES. "?") THEN GOTO NO_SEARCH $ SEARCH = F$EXTRACT (1,255,P1) $ P1=" " $ GOTO NO_ALTS $! $ NO_SEARCH: $ IF (F$EXTRACT(1,1,P1) .NES. "$") THEN GOTO NO_CMD $ NEWCMD = F$EXTRACT (2,255,P1) $ P1=" " $ GOTO NO_ALTS $ NO_CMD: $ LINENO = F$EXTRACT (1,255,P1) $ p1="" $! $ NO_ALTS: $ LIST== F$EDIT ("''P2' ''P3' ''P4' ''P5' ''P6' ''P7'", - "UPCASE ,COMPRESS,TRIM") $ NO_LINE: $! $! Parameters are passed through the JOB logical table. $! $ DEFINE/JOB/NOLOG TPU$SEARCH "''SEARCH'" $ DEFINE/JOB/NOLOG TPU$LINE "''LINENO'" $ DEFINE/JOB/NOLOG TPU$OUTPUT "''OUTPUT'" $ DEFINE/JOB/NOLOG TPU$ARGS " ''LIST'" $ DEFINE/JOB/NOLOG TPU$NEWCMD "''NEWCMD'" $ DEFINE/JOB/NOLOG TPU$ATTACH_NAME "''f$getjpi("","prcnam")'" $! $! Restore all prior privileges. $! $ WRITE SYS$ERROR "[Attaching to editor]" $ DEFINE/NOLOG SYS$INPUT SYS$COMMAND: $ RESUME/NAME="''EDIT_NAME'" $ ATTACH "''EDIT_NAME'" $ WRITE SYS$ERROR "[Back from edit]" $ SUSPEND/NAME="''EDIT_NAME'" $! $! Exit the editor, deleting the journal files. $! $ DONE: $ DEASSIGN/JOB TPU$ATTACH_NAME $ DEASSIGN/JOB TPU$SEARCH $ DEASSIGN/JOB TPU$LINE $ DEASSIGN/JOB TPU$OUTPUT $ DEASSIGN/JOB TPU$ARGS $ DEASSIGN/JOB TPU$NEWCMD $ EXIT *$*$*EOD*$*$* $ if f$search("EXE.DIR;1") .eqs. "" then - CREATE/LOG/DIRECTORY [.EXE] $ write sys$output "Creating [.EXE]VISETUP.COM" $ create [.EXE]VISETUP.COM $ DECK/DOLLARS="*$*$*EOD*$*$*" $ ! $ ! VISETUP.COM - Set up to use the VI TPU interface. $ ! $ ! Written by Gregg Wonderly JUN-30-1987 $ ! $ DEFINE/NOLOG/TRANS=CONCEAL VI$ROOT MATH0:[PUBLIC.VI.] $ DEFINE TPUSECINI VI$ROOT:[EXE]VI.GBL $ DEFINE TPU$CALLUSER VI$ROOT:[EXE]TPUSUBS.EXE $ DEFINE/NOLOG VISECINI VI$ROOT:[EXE]VI.GBL $ DEFINE/NOLOG VI$CALLUSER VI$ROOT:[EXE]TPUSUBS.EXE $ DEFINE/NOLOG MAIL$EDIT VI$ROOT:[EXE]MAILEDIT.COM $! $! This symbol gets you a NON-SPAWNED VI $! Delete this if you are using VI.EXE and VI.CLD $! $ VI == "EDIT/TPU" $! This symbol gets you a SPAWNED VI $ VIS == "@VI$ROOT:[EXE]VI.COM" $! $! This gets you a readonly version of the file. $! $ IF F$TYPE (VI) .EQS. "" THEN VI="VI" $ VIEW == "''VI'/READONLY" $ EXIT *$*$*EOD*$*$* $ if f$search("EXE.DIR;1") .eqs. "" then - CREATE/LOG/DIRECTORY [.EXE] $ write sys$output "Creating [.EXE]MAILEDIT.COM" $ create [.EXE]MAILEDIT.COM $ DECK/DOLLARS="*$*$*EOD*$*$*" $ ! $ ! Command procedure to invoke an editor for MAIL. $ ! $ ! Inputs: $ ! $ ! P1 = Input file name. $ ! P2 = Output file name. $ ! $ ! If MAIL$EDIT is undefined, MAIL will invoke callable EDT. $ ! If MAIL$EDITis defined to be a command procedure, $ ! MAIL will create a subprocess to edit the mail. $ ! $ ! Note that this procedure is run in the context of a subprocess. $ ! LOGIN.COM is not executed. However, all process logical names $ ! and DCL global symbols are copied. $ ! $ ! The default directory is the same as the parent process $ ! $ IF P1 .EQS. "" THEN GOTO NOINPUT $ @VI$ROOT:[EXE]VI 'P1' /OUTPUT='P2' "" "" "" "" "" "NOSPAWN" $ EXIT $ NOINPUT: $ @VI$ROOT:[EXE]VI 'P2' "" "" "" "" "" "" "NOSPAWN" $ EXIT *$*$*EOD*$*$* $ if f$search("EXE.DIR;1") .eqs. "" then - CREATE/LOG/DIRECTORY [.EXE] $ write sys$output "Creating [.EXE]DO.COM" $ create [.EXE]DO.COM $ DECK/DOLLARS="*$*$*EOD*$*$*" $ v=f$verify(0) $! $! DO.COM $! $! Written by Gregg Wonderly 30-Oct-1986 $! $! write sys$output "$ ''P1' ''P2' ''P3' ''P4' ''P5' ''P6' ''P7' ''P8'" $ write sys$output "$ ",P1," ",P2," ",P3," ",P4," ",P5," ",P6," ",P7," ",P8 $ 'P1' 'P2' 'P3' 'P4' 'P5' 'P6' 'P7' 'P8' $ EXIT $status+('f$verify(v)'*0) *$*$*EOD*$*$* $ if f$search("EXE.DIR;1") .eqs. "" then - CREATE/LOG/DIRECTORY [.EXE] $ write sys$output "Creating [.EXE]VI.CLD" $ create [.EXE]VI.CLD $ DECK/DOLLARS="*$*$*EOD*$*$*" ! ! CLD for VI. Derived from the CLD for the EDIT command ! This CLD redefines the default values for the parameters to EDIT/TPU so ! that VI is the default section file instead of EVE. ! define verb vi image VI$ROOT:[EXE]VI.EXE parameter P1 , label=FILE_NAME , prompt="File" value (list,type=$infile) qualifier SECTION default value (default="VISECINI",type=$infile) qualifier LISTING value (type=$outfile) qualifier OUTPUT value (type=$outfile) qualifier READ_ONLY qualifier UPDATE value (list) placement=local qualifier COMMAND default value (DEFAULT="VIINI",TYPE=$INFILE) qualifier RECOVER qualifier JOURNAL default value (type=$infile) qualifier DISPLAY default value (list,type=$infile) qualifier CREATE default qualifier TPU default Sectxpris tyand T all