From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 23-APR-1989 03:06
To:	MRGATE::"ARISIA::EVERHART"
Subj:	PIPE.2_of_4

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Sun, 23 APR 89 21:12:20 PDT
Received: from relay.ubc.ca by KL.SRI.COM with TCP; Sun, 23 Apr 89 21:12:21 PDT
Received: by relay.ubc.ca (5.59/1.14)
	id AA06367; Sun, 23 Apr 89 21:11:05 PDT
Date: 23 Apr 89 22:05 -0600
From: Ken Wallewein <kenw%noah.arc.cdn@relay.ubc.ca>
To: info-vax@kl.sri.com
Message-Id: <3096*kenw@noah.arc.cdn>
Subject: PIPE.2_of_4

+-+-+-+ Beginning of part 2 +-+-+-+
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$!
X$`009LINE = 'P1 'P2 'P3 'P4 'P5 'P6 'P7 'P8
X$!
X$`009WRITE SYS$OUTPUT LINE
X$`009GOTO READ
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "DUPS.BAS"
$ CHECKSUM_IS = 537551969
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X1       ! grpDUP.BAS V1.0 - PIPE DUPS FINDER !
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        DECLARE INTEGER CONSTANT        TRUE  = -1
X        DECLARE INTEGER CONSTANT        FALSE =  0
X
X        DECLARE INTEGER CONSTANT        INP = 1
X        DECLARE INTEGER CONSTANT        OUT = 2
X        DECLARE INTEGER CONSTANT        ECH = 3
X
X        COMMAND_BUFFER$ = SPACE$(80)
X
X        OPEN "SYS$OUTPUT"  FOR OUTPUT AS FILE #OUT,     &
X                RECORDSIZE 132
X        OPEN "SYS$COMMAND" AS FILE #ECH
X
X10      STATUS% = LIB$GET_FOREIGN(COMMAND_BUFFER$,,COMMAND_LENGTH%)
X        IF STATUS% <> SS$_NORMAL
X        THEN
X            PRINT #ECH, '%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            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                OS% = S%
X                S% = INSTR(OS%+1%,COMMAND$,' ')
X            NEXT
X
X        END IF
X
X        ! START AND END OF COMPARE
X        START% = VAL(P$(1%))
X        LENGTH% = VAL(P$(2%))
X        IF LENGTH% = 0%
X        THEN
X                LENGTH% = 999%
X        END IF
X
X        SAVED_LINE$ = ""
X        SAVED_SUBSTR$ = ""
X        SAVED_LINE_WRITTEN% = FALSE
X
X        LINLEN% = 0%
X        MAXLEN% = 128%
X
X100     LINPUT LINE$
X        SUBSTR$ = MID$(LINE$,START%,LENGTH%)
X        IF SUBSTR$ = SAVED_SUBSTR$
X        THEN
X            IF NOT SAVED_LINE_WRITTEN%
X            THEN
X                PRINT #OUT
X                PRINT #OUT, SAVED_LINE$; "   ";
X                LINLEN% = LEN(SAVED_LINE$)+3%
X                SAVED_LINE_WRITTEN% = TRUE
X            END IF
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        ELSE
X            SAVED_LINE$ = LINE$
X            SAVED_SUBSTR$ = SUBSTR$
X            SAVED_LINE_WRITTEN% = FALSE
X        END IF
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

$ FILE_IS = "DUPS.COM"
$ CHECKSUM_IS = 1531336782
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!       NODUPS.COM - REMOVES DUPLICATE RECORDS FROM TEXT FILES
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$       OFFSET = P1
X$       LENGTH = P2
X$       IF LENGTH .EQ. 0 THEN LENGTH = 999      ! START AND END OF COMPARE
X!
X$       SAVED_SUBSTR = ""
X!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$       SUBSTR = F$EXTRACT(OFFSET,LENGTH,LINE)
X$       IF SUBSTR .EQS. SAVED_SUBSTR THEN GOTO READ
X$       SAVED_SUBSTR = SUBSTR
X$       WRITE SYS$OUTPUT LINE
X$       GOTO READ
X$DONE:
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "ECHO.COM"
$ CHECKSUM_IS = 622223558
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$!`009echo.COM - echo arguments
X$!
X$!`009WRITE SYS$OUTPUT "p1:''p1, p2:''p2, p3:''p3, p4:''p4, p5:''p5, "
X$`009WRITE SYS$OUTPUT "''p1' ''p2' ''p3' ''p4' ''p5' "
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "EDIT.COM"
$ CHECKSUM_IS = 1968973785
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$!`009edit.COM - edit line with f$edit()
X$!`009`009 - arguments: p1: list of f$edit() operation eg: trim,compress
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$`009WRITE SYS$OUTPUT f$edit(LINE,p1)
X$`009GOTO READ
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "ELEMENT.COM"
$ CHECKSUM_IS = 928646472
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!`009element.COM - pass selected element of line
X!`009`009    - delimiter: any combination spaces/tabs
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
V$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`03
X2
X
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$`009PARTS = "F$ELEMENT('P1,"" "",LINE)
X$`009IF P2 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P2,"" "",LINE)
X$`009IF P3 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P3,"" "",LINE)
X$`009IF P4 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P4,"" "",LINE)
X$`009IF P5 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P5,"" "",LINE)
X$`009IF P6 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P6,"" "",LINE)
X$`009IF P7 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P7,"" "",LINE)
X$`009IF P8 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P8,"" "",LINE)
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009LINE = F$EDIT(LINE,"COMPRESS")
X$`009WRITE SYS$OUTPUT 'PARTS
X$`009GOTO READ
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "EXTRACT.COM"
$ CHECKSUM_IS = 427562485
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X! EXTRACT.COM - pass selected element of line
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
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$`009PARTS := F$EXTRACT('P1,'P2,LINE)
X$`009IF P4 .NES. "" THEN PARTS = PARTS + "+F$EXTRACT('P3,'P4,LINE)"
X$`009IF P6 .NES. "" THEN PARTS = PARTS + "+F$EXTRACT('P5,'P6,LINE)"
X$`009IF P8 .NES. "" THEN PARTS = PARTS + "+F$EXTRACT('P7,'P8,LINE)"
X$
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009WRITE SYS$OUTPUT 'PARTS
X$`009GOTO READ
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "FIL2DIR.COM"
$ CHECKSUM_IS = 890055752
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$! fil2dir - create directory spec from file spec
X$!
X$!`009dev:[dir]nam.typ;ver => dev:[dir.nam]
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$loop:
X$`009read sys$input/end=done parm
X$`009write sys$output -
X`009`009f$element(0,"]",parm)-
X`009`009+"."-
X`009`009+f$element(0,".",f$element(1,"]",parm))-
X`009`009+"]"
X$`009goto loop
X$
X$done:
$ GOSUB UNPACK_FILE

$ FILE_IS = "ITEM.COM"
$ CHECKSUM_IS = 1767254573
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!item.com - get the item following a given item in a line
X! `009  - eg: in "name: kenw address: calgary", "item address" gets "calgary"
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$`009PARTS = "F$ELEMENT('P1,"" "",LINE)
X$`009IF P2 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P2,"" "",LINE)
X$`009IF P3 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P3,"" "",LINE)
X$`009IF P4 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P4,"" "",LINE)
X$`009IF P5 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P5,"" "",LINE)
X$`009IF P6 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P6,"" "",LINE)
X$`009IF P7 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P7,"" "",LINE)
X$`009IF P8 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P8,"" "",LINE)
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009LINE = F$EDIT(LINE,"COMPRESS")
X$`009WRITE SYS$OUTPUT f$element(1," ",f$extract(f$locate(p1,line),999,line))
X$`009GOTO READ
X$DONE:
$ GOSUB UNPACK_FILE

$ FILE_IS = "LOCAL_COPIES.COM"
$ CHECKSUM_IS = 523901583
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
V! local_copies.com - compares revision dates of p1 and p2, copies p1 to p2 if
X`032
X!`009`009     anything has changed, and mails a message to p3
X!`009`009   - used with PIPE and local_copies.dat
X!
X$ if f$cvtime(f$file_attributes(p1,"rdt")) -
X`009.les.f$cvtime(f$file_attributes(p2,"rdt"))  -
X  then exit
X$
X$ copy 'p1 'p2
X$ pu 'p2/keep=2
X$ mail sys$input /to='p3/subject="''p1' has been copied to ''p2'"`032
X
XThis message was automatically generated by the 'LOCAL_COPIES' procedure.
XContact the system administrator if you  have any questions.
X
X$
$ GOSUB UNPACK_FILE

$ FILE_IS = "LOCAL_COPIES.DAT"
$ CHECKSUM_IS = 926425549
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
XARGUS::USERS:[PEOPLE.DOC]WHOIS.LIS`009SYS$SYSTEM:WHOIS.LIS`009KENW
XGEORGE::OWNERS:[ORANGE]BOSSES.DIS`009SYS$MANAGER:BOSSES.DIS`009THEKID,SYSTEM
$ GOSUB UNPACK_FILE

$ FILE_IS = "NOCTRL.C"
$ CHECKSUM_IS = 891367336
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/*
Xnoctrl.c - removes control characters from files
X`009 - useful for looking at ascii test in object files
X*/
X
X#define EOF -1
X
Xmain()
X`123
X        int byte,chrcnt;
X
X        chrcnt = 0;
X
X        while ( ( byte = getchar() ) != EOF )
X        `123
X                if      (byte > 31 & byte < 127)
X                `123
X                        putchar( byte );
X                        if (chrcnt++ > 76)
X                        `123
X                                printf( "\n" );
X                                chrcnt = 0;
X                        `125
X                `125
X        `125
X`125
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "NODUPS.COM"
$ CHECKSUM_IS = 1531336782
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X!       NODUPS.COM - REMOVES DUPLICATE RECORDS FROM TEXT FILES
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$       OFFSET = P1
X$       LENGTH = P2
X$       IF LENGTH .EQ. 0 THEN LENGTH = 999      ! START AND END OF COMPARE
X!
X$       SAVED_SUBSTR = ""
X!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$       SUBSTR = F$EXTRACT(OFFSET,LENGTH,LINE)
X$       IF SUBSTR .EQS. SAVED_SUBSTR THEN GOTO READ
X$       SAVED_SUBSTR = SUBSTR
X$       WRITE SYS$OUTPUT LINE
X$       GOTO READ
X$DONE:
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "PIPE.COM"
$ CHECKSUM_IS = 455867013
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ SAVE_VERIFY='F$VERIFY(FORCE_VERIFY)
X!
X! PIPE.COM v3.6 - DATA PIPE SIMULATOR
X!
X!`009usage:
X!`009`009PIPE [<infile] [command [args...]] [>outfile] [`124...]
X!`009`009`009e.g. PIPE DIR [*...] SORT `124DUPS >DUPLICATES.DIR
X!`009`009Note operator '+' - allow commands like:
X!`009`009`009PIPE DIR *.FOR `124 +FORTRAN    (like XARGS FORTRAN)
X!
X!
X$! history:
X$! 890406 kenw`009drop input redirection in "push" mode
X$! 890403 kenw`009correct verify handling to handle batch properly
X$! 890402 kenw`009added "?" operator, interactive mode
X$! 890219 kenw`009make &LINE handler manual, add FIL2DIR filter
X$! 890126 kenw`009add quoted-string parser
X$! 890124 kenw`009add 'item' filter
X$! 890120 kenw`009turn off verify in batch
X$! 890105 kenw`009add "+" operator to replace '&LINE' for in-line data,
X$!`009`009changed definition of 'echo' to symbol
X$! 890104 kenw`009add ";" operator for multiple sequential command lines
X$! 881201 kenw`009changed scratch file naming to make unique
X$! 880713 kenw`009Fix verify handling: "'" in front of F$VERIFY causes it
X$!`009`009to execute BEFORE interpreting, else vice versa.
X$!`009`009Added "seen command" display.
X$!
X$!
X$!`009setup definitions:
X$!`009`009symbol PIPE for command execution
X$!`009`009logical PIPE for package location (default: PIPE.COM location)
X$!
X$!`009there are 3 major sections:
X$!`009`009initialization - define local symbols
X$!`009`009parsing - take a command from SYS$INPUT, parse it
X$!`009`009execution - process the command
X$!
X$!`009bugs:
X$!`009`009- there may be some problems with input by command files
X$!`009`009with redirected channels under wierd circumstances; caused`032
X$!`009`009by DCL switching source of input at EOF.
-+-+-+-+-+ End of part 2 +-+-+-+-+-

