From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM"  8-JUL-1993 09:57:03.81
To:	EVERHART
CC:	
Subj:	VMS TAIL in MACRO

X-Newsgroups: comp.os.vms
Subject: VMS TAIL in MACRO
Message-ID: <1993Jul8.134538.936@iwsd01.itwol.bhp.com.au>
From: WETIBD@itwol.bhp.com.au (Daiajo Tibdixious)
Date: 8 Jul 93 13:45:37 +1000
Distribution: world
Organization: BHP Information Technology
Nntp-Posting-Host: devax1
Nntp-Posting-User: weabep
X-News-Reader: VMS NEWS 1.11
Lines: 210
To: Info-VAX@KL.SRI.COM
X-Gateway-Source-Info: USENET

This is freeware, don't try to sell it.

Original credit to Peter Ward of DEC while contracted to us.
He just "whipped" it up one day. No support is provided.

I did add the "1$:" and "2$:" so that this would unpack in this simple format.
Just cut out the below, and "@" it. It will unpack and build.
--
$create /log TAIL.CLD
define verb TAIL image "UTILITY_ROOT:[TAIL]TAIL.EXE"

    	qualifier LINES , nonnegatable
		, value ( type = $NUMBER , required )

    	parameter P1 , label = INFILE , prompt = "Input file"
		, value ( type = $FILE , required )
$create /log TAIL.MAR
	.TITLE	TAIL

	DEF_LINES = 20
	LINES_LEN = 10
	MAXREC = 512

1$:	$STSDEF
2$:	$SHRDEF

	.PSECT	DATA	WRT,NOEXE

INFAB:	$FAB	DNM=<SYS$DISK:[].LIS;>,-
		FAC=<GET>,-
		SHR=<UPD>,-
		NAM=INNAM

INNAM:	$NAM	ESA=EXP_SPEC,-
		ESS=NAM$C_MAXRSS

INRAB:	$RAB	FAB=INFAB,-
		RAC=SEQ,-
		ROP=<RAH>,-
		UBF=REC_BUF,-
		USZ=MAXREC

OPENIN_MSG:
	.WORD	1
	.WORD	0
	.LONG	SHR$_OPENIN ! STS$K_ERROR
	.ADDRESS	EXP_DESC

TAIL_FAC:
	.ASCID	/TAIL/

FILE_SPEC:
	.BLKB	NAM$C_MAXRSS
FILE_DESC:
	.WORD	NAM$C_MAXRSS
	.WORD	0
	.ADDRESS	FILE_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#1,G^LIB$STOP
	RET
ERROR2:	PUSHL	R1
	PUSHL	R0
	CALLS	#2,G^LIB$STOP
	RET
	.END	TAIL
$	macro TAIL
$	link TAIL
$	dir TAIL.CLD,.MAR,.OBJ,.EXE

--
Daiajo Tibdixious	wetibd%devax1.dnet@itwol.bhp.com.au
Australia  BHP IT Wol  Facilities Management  DEC System Support
MIPS - Meaningless Information Provided by Salesperson

