HP OpenVMS Systems

ask the wizard
Content starts here

Accessing RMS data from Pascal?

» close window

The Question is:

I want to get a files creation date from a PASCAL program.
I can't figure the $display call.
I have
Program abc
   rab_ptr,  fab_ptr : integer := 0;
fdl$parse('login.com', rab_ptr, fab_ptr);
$display(fab_ptr, ?, ? );
How do I use "$display" ?
     Allan Dillon

The Answer is :

  Some misunderstandings here. First, the FDL$PARSE routine reads and parses
  an FDL file. So, unless you place FDL code in your LOGIN.COM procedure,
  there's a problem!
  The general rule with RMS programming is, if you don't need something,
  don't talk about it. So, in your $DISPLAY call, since you're probably
  not interested in the AST completions, just leave them out.
  However, none of this gets you closer to your stated goal of finding the
  creation date of a file. Perhaps this example will help:
Example-Pascal  Using PAS$FAB To Display Creation/Revision Dates
COPYRIGHT (c) 1988, 1993 by Digital Equipment Corporation.
ALL RIGHTS RESERVED. No distribution except as provided under contract.
Copyright (c) Digital Equipment Corporation 1991. All rights reserved
LAYERED PRODUCT:  VAX Pascal                      OP/SYS: VMS
SOURCE:     Digital Customer Support Center
The program demonstrates how to use PAS$FAB and $DISPLAY to retrieve
the creation and revision dates of a file.
*** CAUTION ***
This sample program has been tested using VAX Pascal Version 4.2 on
VMS Version 5.4.  However, we cannot guarantee its effectiveness
because of the possibility of error in transmitting or implementing
it.  It is meant to be used as a template for writing your own
program and it may require modification for use on your system.
Normally, a user-action procedure is used to get access to the RMS
structures such as the FAB.  However, the PAS$FAB function will return
a pointer to the FAB that was opened with the Pascal OPEN statement.
Please see Appendix D, "Pascal Reference Supplement for VMS Systems",
December 1989, for more information on PAS$FAB.
Please see the "VMS Record Management Services Manual", April 1988,
for more information on $DISPLAY.
CAUTION:  You should take care that your use of the RMS FAB does not
interfere with the normal operations of the Run-Time Library.  Future
changes to the Run-Time Library may change the way in which the FAB is
used, which may in turn require you to change your program.
[inherit ('sys$library:starlet','sys$library:pascal$lib_routines')]
program get_data_and_time (input,output);
  ptr_fab = ^fab$type;
function pas$fab (var f : [unsafe] text) : ptr_fab; extern;
  stat            : integer;
  fabp            : ptr_fab;
  xab_dat,xab_rdt : xab$type;
  creation_time   : varying [23] of char;
  revision_time   : varying [23] of char;
  filename        : varying [255] of char;
  f               : text;
  write('Enter file name >> ');
  open (file_variable := f, file_name := filename, history := readonly);
  fabp := pas$fab (f);
  fabp^.fab$l_xab := iaddress(xab_dat);
  xab_dat := zero;
  xab_dat.xab$b_cod := xab$c_dat;
  xab_dat.xab$b_bln := xab$c_datlen;
  xab_dat.xab$l_nxt := iaddress(xab_rdt); { chain the two xab'x together }
  xab_rdt := zero;
  xab_rdt.xab$b_cod := xab$c_rdt;
  xab_rdt.xab$b_bln := xab$c_rdtlen;  { the xab$l_nxt field will be zero }
  stat := $display(%immed fabp);
  if not odd(stat) then lib$stop(stat);
  stat := $asctim(creation_time.length,creation_time.body,xab_dat.xab$q_cdt);
  if not odd (stat) then lib$stop(stat);
  writeln('file creation time is ',creation_time);
  stat := $asctim(revision_time.length,revision_time.body,xab_rdt.xab$q_rdt);
  if not odd (stat) then lib$stop(stat);
  writeln('file revision time is ',revision_time);

answer written or last revised on ( 5-SEP-2000 )

» close window