From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 26-APR-1989 15:16
To:	MRGATE::"ARISIA::EVERHART"
Subj:	PIPE.4_of_4

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 26 APR 89 10:13:32 PDT
Received: from relay.ubc.ca by KL.SRI.COM with TCP; Wed, 26 Apr 89 10:11:44 PDT
Received: by relay.ubc.ca (5.59/1.14)
	id AA10231; Wed, 26 Apr 89 10:10:23 PDT
Date: 26 Apr 89 11:09 -0600
From: Ken Wallewein <kenw%noah.arc.cdn@relay.ubc.ca>
To: <info-vax@kl.sri.com>
Message-Id: <2860*kenw@noah.arc.cdn>
Subject: PIPE.4_of_4

+-+-+-+ Beginning of part 4 +-+-+-+
X$`009DEFINE PIPE 'here']
X$
X$`009P*IPE`009`009:== @PIPE:PIPE """"`009! pass everything verbatim
X$`009SUBS*TITUTE`009:== @PIPE:SUBSTITUTE
X$`009PA`009`009:== @PIPE:PURGABLE`009! do NOT use PU*RGABLE!!!
X$`009DO`009`009:== SPAWN/NOWAIT/NOTIFY -
X`009`009`009`009/INPUT=NL:/OUTPUT=SYS$SCRATCH:DO.LOG
X$`009`009`009`009`009`009! easy background tasks
X$`009FORCE_VERIFY`009== "''FORCE_VERIFY'"`009! be sure it's defined for PIPE
X$
$ GOSUB UNPACK_FILE

$ FILE_IS = "PURGABLE.COM"
$ CHECKSUM_IS = 554239451
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ say "purgable.com - show purgable files"
X$ say "working..."
X$
X$ on error then goto exit
X$ on control_y then goto exit
X$
X$ file_name := SYS$SCRATCH:purgable.lis
X$
X$ dir/notr/siz/col=1/out='file_name 'p1
X$ filnam1 = f$search(file_name)
X$
X$ dir/notr/siz/col=1/out='file_name 'p1;
X$ filnam2 = f$search(file_name)
X$
X$ diff/sep=master 'filnam1 'filnam2
X$
X$exit:
X$ if "''filnam1'" .nes. "" then delete 'filnam1
X$ if "''filnam2'" .nes. "" then delete 'filnam2
$ GOSUB UNPACK_FILE

$ FILE_IS = "SKIP.COM"
$ CHECKSUM_IS = 2084386474
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X! SKIP.COM - skip n lines at beinning of input`032
X!`009   - synopsis: skpi lines
X!
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
V$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT
X`032
V$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTP
XUT
X$
X$`009skipcnt = f$integer(p1)+1
X$SKIP:`009skipcnt = skipcnt-1
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009if skipcnt .ne. 0 then goto skip
X$`009WRITE SYS$OUTPUT line
X$       GOTO READ
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "STEM.BAS"
$ CHECKSUM_IS = 1746151268
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X1       ! STEM.BAS V1.0 - PIPE STEM !
X        ON ERROR GOTO 32000
X
X        EXTERNAL LONG FUNCTION LIB$GET_FOREIGN
X        EXTERNAL INTEGER CONSTANT SS$_NORMAL
X
X        DIM P$(31)
X
X        COMMAND_BUFFER$ = SPACE$(80)
X
X        OPEN "SYS$COMMAND" AS FILE #1%
X
X10      STATUS% = LIB$GET_FOREIGN(COMMAND_BUFFER$,,COMMAND_LENGTH%)
X        IF STATUS% <> SS$_NORMAL
X        THEN
X            PRINT #1%, '%GET_COMMAND error'; STATUS%
X            GOTO 32767
X        END IF
X
X        CMD_CNT% = 0%
X
X        IF COMMAND_LENGTH% > 0%
X        THEN
X
X            COMMAND$ = LEFT$(COMMAND_BUFFER$,COMMAND_LENGTH%) + ' '
X
X        !   PRINT #1%, 'COMMAND WAS: "'; COMMAND$; '"'
X
X            OS% = 0%
X            S% = INSTR(OS%+1%,COMMAND$,' ')
X
X            WHILE S% > 0%
X                CMD_CNT% = CMD_CNT%+1%
X                P$(CMD_CNT%) = MID$(COMMAND$,OS%+1%,S%-OS%-1%)
X        !       PRINT #1%, 'P$(';CMD_CNT%;'): "'; P$(CMD_CNT%); '"'
X                OS% = S%
X                S% = INSTR(OS%+1%,COMMAND$,' ')
X            NEXT
X
X20      ! READ LOOP
X        LINPUT A$
X        GOSUB 100
X        PRINT A$
X        GOTO 20
X
X100     ! YOUR CODE HERE
X        ! NOTE:
X        !       AVAILABLE HERE ARE THE FOLLOWING COMMAND LINE VARIABLES:
X        !       COMMAND$ - CONTAINS ALL OPTIONS INCLUDED WITH THE COMMAND
X        !       P$()     - CONTAINS OPTIONS PARSED BY SPACES
X        !       CMD_CNT% - CONTAINS NUMBER OF OPTIONS FOUND
X
X999     RETURN
X
X32000   ! ERROR TRAPS
X
X        IF ERR=11       ! NORMAL EOF?
X        THEN
X                IF ERL=20
X                THEN
X                        RESUME 32767
X                END IF
X        END IF
X
X32100 ON ERROR GOTO 0   ! FATAL ERRORS
X
X32767 END
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "STEM.C"
$ CHECKSUM_IS = 1380208176
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/* stem.c v1.0 - pipe stem */
X
X#define EOF -1
X
Xmain()
X`123
X        int byte;
X
X        while ( (byte=getchar()) != EOF )
X        `123
X                /* your code here */
X                putchar( byte );
X        `125
X`125
X`032
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "STEM.COM"
$ CHECKSUM_IS = 1312981018
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$!`009PIPESTEM.COM - STUB FRONT END FOR COM FILES USED BY PIPE
X$!
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
V$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`03
X2
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$!
X$!`009PUT CODE HERE...
X$!
X$`009WRITE SYS$OUTPUT LINE
X$`009GOTO READ
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "STEMS.C"
$ CHECKSUM_IS = 573192461
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/* stems.c - line oriented c pipestem */
X
Xchar *string[255];
X
Xmain()
X`123
X        while ( gets( string ) )
X        `123
X
X                /* your code here */
X
X                puts( string );
X        `125
X`125
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "SUBSTITUTE.COM"
$ CHECKSUM_IS = 625871281
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!SUBSTITUTE.COM V1.0 - search/substitute on a file using FORALL and EDT
X!
X$    on error then goto edit
X$    on control_y then goto exit
X$
X$    if p1 .eqs. "" .or. p2 .eqs. "" then goto badargs
X$
X$    file_name := SYS$SCRATCH:SUBSTITUTE.EDT
X$
X$    open/write file 'file_name
X$    filnam = f$search(file_name)
X$
X$    write file "subs`126''p2'`126''p3'`126w/not"
X$    write file "ex"
X$    close file
X$
X$    pipe dir 'p1 `124 +EDITt/COMMAND='filnam
X$    goto exit
X$
X$badargs:
X$    write sys$output "SUBSTITUTE filespec search_string [substitute_string]"
X$
X$exit:
X$    if f$trnlnm("file") .nes."" then -
X            close file
X$    if "''filnam'" .nes. "" .or. f$trnlnm("file") .nes."" then -
X            delete 'filnam
$ GOSUB UNPACK_FILE

$ FILE_IS = "TEE.COM"
$ CHECKSUM_IS = 1148747366
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!       tee.COM - send a copy of sys$input to specified file
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
V$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT
X`032
V$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTP
XUT
X$
X$`009if p1 .eqs. "" then p1 := tt:
X$
X$`009open/write file 'p1
X$
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`032
X$`009write file line
X$
X$       WRITE SYS$OUTPUT LINE
X$       GOTO READ
X$DONE:
X$`009close file
$ GOSUB UNPACK_FILE

$ FILE_IS = "TIME.COM"
$ CHECKSUM_IS = 1565686740
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!time.com - times stuff
X!
X$`009prev_time = "''time'"
X$`009time == 'f$cvtime(,,"second")*100 + 'f$cvtime(,,"hundredth")
X$`009elapsed = time - prev_time
X$
X$CMD := 'P1 'P2 'P3 'P4 'P5 'P6 'P7 'P8
X$
X$`009IF CMD .EQS. "" THEN goto done
X$
X$'cmd
X$
X$`009prev_time = 'time
X$`009time == 'f$cvtime(,,"second")*100 + 'f$cvtime(,,"hundredth")
X$`009elapsed = time - prev_time
X$
X$done:
X$`009secs = elapsed/100
X$`009hund = elapsed - secs*100
X$`009write sys$output "elapsed: ''secs'.''hund'"
$ GOSUB UNPACK_FILE

$ FILE_IS = "TOTAL.COM"
$ CHECKSUM_IS = 779694361
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!       TOTAL.COM - total up all items in given column
X!`009`009  - parameters: column_offset length [output_file]
X!
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
V$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT
X`032
V$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTP
XUT
X$!
X$`009total = 0
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$!
X$`009total = total + f$integer(f$extract('p1,'p2,line))
X$!
X$       if p3 .nes. "" then WRITE SYS$OUTPUT line
X$       GOTO READ
X$DONE:
X$       if p3 .eqs. "" then WRITE SYS$OUTPUT total
X$       if p3 .nes. "" then WRITE 'p3 total
$ GOSUB UNPACK_FILE

$ FILE_IS = "WIDE.BAS"
$ CHECKSUM_IS = 1761703608
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X1       ! WIDE.BAS V1.0 - PIPE WIDE LIST PRINTER !
X        ON ERROR GOTO 32000
X
X        EXTERNAL LONG FUNCTION LIB$GET_FOREIGN
X        EXTERNAL INTEGER CONSTANT SS$_NORMAL
X
X        DECLARE INTEGER CONSTANT        TRUE  = -1
X        DECLARE INTEGER CONSTANT        FALSE = 0
X
X        DECLARE INTEGER CONSTANT        OUT   = 2
X
X        COMMAND_BUFFER$ = SPACE$(80)
X
X        OPEN "SYS$OUTPUT"  FOR OUTPUT AS FILE #OUT,     &
X                RECORDSIZE 132
X
X10      STATUS% = LIB$GET_FOREIGN(COMMAND_BUFFER$)
X        MAXLEN% = VAL(COMMAND$)
X        MAXLEN% = 128%  UNLESS MAXLEN%
X
X        LINLEN% = 0%
X
X100     LINPUT LINE$
X
X        IF LINLEN%+LEN(LINE$) > MAXLEN%
X        THEN
X                PRINT #OUT
X                LINLEN%=0%
X        END IF
X        PRINT #OUT, LINE$; "   ";
X        LINLEN% = LINLEN%+LEN(LINE$)+3%
X
X        GOTO 100
X
X
X32000   ! ERROR TRAPS
X
X        IF ERR=11       ! NORMAL EOF?
X        THEN
X                IF ERL=100
X                THEN
X                        PRINT #OUT
X                        RESUME 32767
X                END IF
X        END IF
X
X32100 ON ERROR GOTO 0   ! FATAL ERRORS
X
X32767 END
X
$ GOSUB UNPACK_FILE
$ EXIT
-+-+-+-+-+ End of part 4 +-+-+-+-+-

