From:	SMTP%"carl@SOL1.GPS.CALTECH.EDU" 10-JUN-1994 15:01:53.32
To:	EVERHART
CC:	
Subj:	Re: version_limit of a file

X-Newsgroups: comp.os.vms
Subject: Re: version_limit of a file
Message-Id: <2t6j2t$171@gap.cco.caltech.edu>
From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
Date: 9 Jun 1994 08:15:25 GMT
Reply-To: carl@SOL1.GPS.CALTECH.EDU
Distribution: world
Organization: HST Wide Field/Planetary Camera
Nntp-Posting-Host: sol1.gps.caltech.edu
Lines: 129
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET

In article <1994Jun8.130238.20589@wuerl.wustl.edu>, allen@wuerl.wustl.edu (Allen Rueter) writes:
=8<---  snip (removed nice c code to find version limit)
=Carl, 
=	Real nice, if you have a C compiler. But it won't be hard to convert
=to macro.

Well, it wouldn't be were I fluent in MACRO.  However, here's what I managed to
cobble together.  It may not be the most efficient code, but it assembles,
links, and runs correctly.  Its error messages aren't terribly informative,
since it simply returns the status from the system service and library routines
it calls, but it works.

.MACRO DESCRIPTOR_D
	$DSCDEF
	.WORD	0
	.BYTE	DSC$K_DTYPE_T
	.BYTE	DSC$K_CLASS_D
	.LONG	0
.ENDM DESCRIPTOR_D
	.PSECT DATA,WRT,NOEXE,LONG,REL
CTLSTR:	.ASCID /!UW/
CMD:	DESCRIPTOR_D
INPFIL:	DESCRIPTOR_D
SYMNAM:	DESCRIPTOR_D
DEVNAM:	.WORD	0
	.BYTE	DSC$K_DTYPE_T
	.BYTE	DSC$K_CLASS_S
	.LONG	0
FILNAM:	.WORD	0     
	.BYTE	DSC$K_DTYPE_T
	.BYTE	DSC$K_CLASS_S
	.LONG	0
FILPTR:	.ADDRESS FILNAM
SPACE:	.ASCID / /
N:	.LONG	0
MY_RSA:	.BLKB	255
MY_ESA:	.BLKB	255
	.ALIGN	LONG
IOSB:	.WORD	4
$FIBDEF
MY_FIB:	.BYTE	0[FIB$C_LENGTH]
	.ALIGN	LONG
FIBDSC:	.LONG	FIB$C_LENGTH
	.LONG	MY_FIB
MY_NAM:	$NAM RSA=MY_RSA, RSS=255, ESA=MY_ESA, ESS=255
	.ALIGN	LONG
MY_FAB:	$FAB NAM=MY_NAM
CHAN:	.BLKW	1
SYMBUF:	.BLKB	5
SYMVAL:	.WORD	5
	.BYTE	DSC$K_DTYPE_T
	.BYTE	DSC$K_CLASS_S
	.ADDRESS SYMBUF

	.PSECT CODE,NOWRT,EXE,LONG,REL
TOP:	.ENTRY	MAIN ^M<>
		PUSHAL	CMD
		CALLS	#1, G^LIB$GET_FOREIGN
		BBS	#0, R0, NXT1
		RET
NXT1:		PUSHAL	CMD
		PUSHAL	SPACE
		PUSHAL	N
		PUSHAL	INPFIL
		CALLS	#4, G^STR$ELEMENT
		BBS	#0, R0, NXT2
		RET
NXT2:		MOVL	#1, N
		PUSHAL	CMD
		PUSHAL	SPACE
		PUSHAL	N
		PUSHAL	SYMNAM
		CALLS	#4, G^STR$ELEMENT
		BBS	#0, R0, NXT3
		RET
NXT3:		MOVL	INPFIL+4, MY_FAB+FAB$L_FNA
		MOVW	INPFIL, MY_FAB+FAB$B_FNS
		MOVB	#0, MY_FAB+FAB$B_FAC
		MOVB	#FAB$M_UPI, MY_FAB+FAB$B_SHR
		PUSHAL	MY_FAB
		CALLS	#1, G^SYS$PARSE
		BBS	#0, R0, NXT4
		RET
NXT4:		PUSHAL	MY_FAB
		CALLS	#1, G^SYS$SEARCH
		BBS	#0, R0, NXT5
		RET
NXT5:		MOVW	MY_NAM+NAM$W_DID_NUM,MY_FIB+FIB$W_DID_NUM
		MOVW	MY_NAM+NAM$W_DID_SEQ,MY_FIB+FIB$W_DID_SEQ
		MOVW	MY_NAM+NAM$W_DID_RVN,MY_FIB+FIB$W_DID_RVN
		MOVL	#FIB$M_NOTRUNC+FIB$M_PRSRV_ATR+FIB$M_NOLOCK+-
				FIB$M_NORECORD, MY_FIB+FIB$L_ACCTL
		MOVZBW	MY_NAM+NAM$B_DEV, DEVNAM+DSC$W_LENGTH
		MOVL	MY_NAM+NAM$L_DEV, DEVNAM+DSC$A_POINTER
		$ASSIGN_S	CHAN=CHAN,DEVNAM=DEVNAM
		BBS	#0, R0, NXT6
		RET
NXT6:		MOVL	MY_NAM+NAM$L_NAME, FILNAM+DSC$A_POINTER
		MOVZBW	MY_NAM+NAM$B_NAME,FILNAM+DSC$W_LENGTH
		MOVZBW	MY_NAM+NAM$B_TYPE,R0
		ADDW	R0,FILNAM+DSC$W_LENGTH
		MOVZBW	MY_NAM+NAM$B_VER,R0
		ADDW	R0,FILNAM+DSC$W_LENGTH
		$QIOW_S	CHAN=CHAN,FUNC=#IO$_ACCESS,IOSB=IOSB,P1=FIBDSC,P2=FILPTR
		BBS	#0, R0, NXT7
		RET
NXT7:		BBS	#0, IOSB, NXT8
		MOVZWL	IOSB, R0
		RET
NXT8:		MOVZWL	MY_FIB+FIB$W_VERLIMIT,-(SP)
		PUSHAL	SYMVAL
		PUSHAW	SYMVAL
		PUSHAL	CTLSTR
		CALLS	#4, G^SYS$FAO
		BBS	#0, R0, NXT9
		RET
NXT9:		PUSHAL	SYMVAL
		PUSHAL	SYMNAM
		CALLS	#2, G^LIB$SET_SYMBOL
QUIT:		RET
	.END	TOP
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.

