From:	SMTP%"fogelinc@pt.Cyanamid.COM" 24-JUN-1993 13:24:23.18
To:	EVERHART
CC:	
Subj:	Summary: How do you get the XAB populated

From: fogelinc@pt.Cyanamid.COM (Carl Fogelin)
X-Newsgroups: comp.os.vms
Subject: Summary: How do you get the XAB populated
Date: 23 Jun 1993 21:10:05 GMT
Organization: American Cyanamid Company
Lines: 60
Distribution: world
Message-Id: <20agrd$kib@c3po.jvnc.net>
Reply-To: fogelinc@pt.Cyanamid.COM
Nntp-Posting-Host: nmr1.pt.cyanamid.com
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET

Thanks to everyone who emailed me what I was doing wrong.  Some of the
problems were typos (that's what I get for retyping in my sample code)
and some were things I just didn't know (like that the XAB must be expli-
citly defined and attached to the FAB.)  I've appended my working sample
which incorporated the suggestions I got.  Thanks again.


#include <stdio.h>
#include <ssdef.h>
#include <libdef.h>
#include <libdtdef.h>
#include <descrip.h>
#include <fab.h>
#include <xab.h>

struct FAB *ffab=0;
struct XABDAT my_xabdat;

int main()
{
   $DESCRIPTOR(ifile,"*.*");
   $DESCRIPTOR(today,"TODAY");
   struct dsc$descriptor_s oname;
   unsigned char qword1[8],qword2[8];
   unsigned long int cvtout = 0, cvtop = LIB$K_DELTA_DAYS;
   int i,status;

   oname.dsc$a_pointer = 0;
   oname.dsc$w_length = 0;
   oname.dsc$b_class = DSC$K_CLASS_D;
   oname.dsc$b_dtype = DSC$K_DTYPE_T;
   my_xabdat = cc$rms_xabdat;

   status = LIB$CONVERT_DATE_STRING(&today,&qword1);
   printf("File mask is: %.*s\n\n",ifile.dsc$w_length,ifile.dsc$a_pointer);
   do {
      status = LIB$FIND_FILE(&ifile,&oname,&ffab);
      if (status & 1) {
         ffab->fab$l_xab = (char *) &my_xabdat;
         status = SYS$OPEN(ffab);
         status = LIB$SUB_TIMES(&qword1,&my_xabdat.xab$q_cdt,&qword2);
	 if (status != LIB$_NEGTIM)
            status = LIB$CVT_FROM_INTERNAL_TIME(&cvtop,&cvtout,&qword2);
	 else
	    cvtout = 0L;
         printf("%.*s is %ld day(s) old\n",
	    oname.dsc$w_length,oname.dsc$a_pointer,cvtout);
         status = SYS$CLOSE(ffab);
	 }
      } while (status & 1);
   status = LIB$FIND_FILE_END(&ffab);
   exit();
   }

---------------------------------------------------------------------------
 Carl Fogelin (fogelinc@pt.cyanamid.com)   "All opinions are strictly mine" 

   Up the long ladder and down the short rope,
   To Hell with King Billy and God bless the Pope. -- traditional


