[comp.os.vms] crdate, revdate access ??

bloedel@uklirb (02/25/88)

Does anyone know how to access the creation-date and the revision-date of
files from a pascal program? 
Is the lexical function f$file_attribute callable from pascal source?

Thanks in advance for any hint on this problem.

best regards   

  J. Bloedel, M. Weber

========================================================================
  Kaiserslautern University, Dept. of Computer Science,
  P.O. Box 3049, D-6750 Kaiserslautern, F.R.G.

  uucp :  abakus%uklirb@unido.uucp
========================================================================

srwhmdr@wnv.dsir.govt.nz (03/03/88)

In article <26200001@uklirb.UUCP>, bloedel@uklirb writes:
> 
> Does anyone know how to access the creation-date and the revision-date of
> files from a pascal program? 
> Is the lexical function f$file_attribute callable from pascal source?
> 

F$FILE_ATTRIBUTES is not callable so you will have to get file attributes
by calling RMS services yourself.  

The following piece of code shows how to get all the date time information
about a file. 

To get date time info you must fill a FAB with the name of the file you want
and link a XABDAT to it to receive the date time info. Then perform an RMS
OPEN which will fill the XABDAT fields which you can then access.

For the program below the open is actually a user-file open which is not a
"real" open but is enough to get the date time info. If you want a "real" open
where you can read or write then don't turn on the FAB$V_UFO bit in the
FAB$L_FOP field. Of you do a 'real" open you will then have to CLOSE the file 
as well.

The other thing is that this program inherits files which contain the
record definitions for tha FAB and XABs. You will have to build these
yourself as DEC do not supply them for some reason. I will indicate
how to do this if requested.

Don't be depressed if this program looks complicated, it's not. It's just
the FAB and XAB definitions look cryptic to the uninitiated.

Have fun..


----------------------------------- Cut here -----------------------------------
[INHERIT ('PAS_ENVIRONMENT:VMS_SYS',	{ system service definitions }
	  'PAS_ENVIRONMENT:VMS_LIB',	{ run-time library definitions }
	  'PAS_ENVIRONMENT:VMS_FAB',	{ Contains FAB record definitions }
	  'PAS_ENVIRONMENT:VMS_XAB')]	{ Contains XAB record definitions }

PROGRAM Get_Time_Information (INPUT, OUTPUT);

{ Return the dates associated with a file without opening the file by
  specifying a user file open (see RMS Reference manual) }

VAR	fname	  : VARYING [255] OF CHAR;
	date_time : VARYING [255] OF CHAR;
	fab	  : FAB$R_FAB;		{ FAB record }
	xab	  : XAB$R_XAB;		{ XAB record }
	stat	  : INTEGER;

BEGIN
  WRITE ('File: ');
  READLN (fname);
  WRITELN;

  fab := ZERO;
  WITH fab DO
  BEGIN
    FAB$B_BID := FAB$C_BID;			{ identify as a FAB }
    FAB$B_BLN := SIZE (fab);			{ size of FAB }
    FAB$L_FNA := IADDRESS (fname.body);		{ file name }
    FAB$B_FNS := fname.length;
    FAB$L_FOP := FAB$M_UFO;			{ user file open }
    FAB$L_XAB := ADDRESS (xab)			{ link in XAB }
  END;

  xab := ZERO;
  WITH xab DO
  BEGIN
    XAB$B_COD := XAB$C_DAT;			{ identify as XABDAT }
    XAB$B_BLN := SIZE (xab);			{ size of XAB }
    XAB$L_NXT := NIL				{ next link goes nowhere }
  END;

  stat := SYS$OPEN (fab);			{ doesn't open file - ufo }
  IF NOT ODD (stat) THEN LIB$STOP (stat);

  WITH xab DO
  BEGIN
    stat := SYS$ASCTIM (date_time.length, date_time.body, XAB$Q_BDT);
    IF NOT ODD (stat) THEN LIB$SIGNAL (stat);
    WRITELN ('Last backup    ', date_time);
    stat := SYS$ASCTIM (date_time.length, date_time.body, XAB$Q_CDT);
    IF NOT ODD (stat) THEN LIB$SIGNAL (stat);
    WRITELN ('Created        ', date_time);
    stat := SYS$ASCTIM (date_time.length, date_time.body, XAB$Q_EDT);
    IF NOT ODD (stat) THEN LIB$SIGNAL (stat);
    WRITELN ('Expires        ', date_time);
    stat := SYS$ASCTIM (date_time.length, date_time.body, XAB$Q_RDT);
    IF NOT ODD (stat) THEN LIB$SIGNAL (stat);
    WRITELN ('Last revised   ', date_time)
  END
END.
----------------------------------- Cut here -----------------------------------