HP OpenVMS Systems

ask the wizard
Content starts here

DIRECTORY sorting, DCL date processing?

» close window

The Question is:

I am trying to create a loop to go backwards in time with DCL. I can't seem to
 get the syntax correct.
What I need to do is to search for all days before the current date and then
 move those files to a different directory and insert them into a database in
 date order.
The problem that I am having is that f$cvtime isn't recognizing anything before
 yesterday and I need to be able to go at least three days back.
What I am trying looks like this:
$ on error then goto error exit
$ set uic [1,4]
$ set proc /priv = all
$ set def ds$edi
$ set def [.vdps]
$ X = 24
$ dayloop:
$ time = f$cvtime("TODAY" - x)
$ time = f$extr(5,5,TIME) - "-"
$ if f$sea("DPS''TIME'.ISO") .NES. ""
$ then
$    x = x + 24
$    goto dayloop
$ else
$    x = x - 24
$    time = f$cvtime("TODAY" - x)
$    time = f$extr(5,5,TIME) - "-"
$    if f$sea("DPS''TIME'.ISO") .nes. ""
$    then
$       copy DPS'TIME'.iso ds$bsc:bsc_dpsar_dsedi.rec;0
$       M
        ZN "DSEDI"
        S PROC="DPSAR"
$       del ds$bsc:bsc_dpsar_dsaec.rec;
$       del DPS'TIME'.ISO;
$       goto dayloop
$    else
$       reply/term = opa0: "BSC MSG: UPLOAD COMPLETE."
$    endif
$ endif
$ exit
The error that I get is this:
$ time = f$cvtime("TODAY" - x)
%DCL-W-IVATIME, invalid absolute time - use DD-MMM-YYYY:HH:MM:SS.CC format
whenever x is larger than 24.
Is there a way to make f$cvtime reverse in this way?

The Answer is :

  Please see the information on absolute, delta, and combination times
  available in the OpenVMS documentation set (The OpenVMS User's Guide,
  the DCL Dictionary) and in the OpenVMS HELP library, and please also
  consider other available reference materials such as the Digital Press
  book Writing Real Programs in DCL.
  In this case, commands such as the following are likely of interest:
   $ DIRECTORY/SINCE="8-JAN-2003-2-"
  You could also use a combination time as the input time value for the
  DCL f$cvtime lexical function -- if wish to continue with your current
  approach based on your DCL procedure.  Please see the OpenVMS manuals
  for details on the particular syntax of the combination time.
  An example of a combination time specification follows:
      f$cvtime("TODAY - ''X'-",,"Month")
  The OpenVMS Wizard would also suggest the use of f$cvtime to extract the
  required portions of the date string, and not parsing the date string
  with f$extract.  (Why introduce a Y10K problem into your own DCL code,
  when a simple and supported -- and also easy for subsequent programmers
  to understand, to debug, and to extend as needed -- alternative exists?)
  Another approach for managing this date data is to load the contents of
  the directory into an indexed file -- using a comparison-format date
  as the (descending) key -- and then access the filename contents of
  the record by its key.  Indexed files are easily available from DCL
  using the READ command, the WRITE command, the CREATE/FDL command,
  and a very simple FDL file.  (The first characters of each record
  would be a string key, containing the comparison-format date.  (The
  OpenVMS Wizard would allow duplicates on this key.)  The remaining
  characters of each record in the file -- this field would be up to
  255 characters wide, assuming ODS-2 -- would be the filename that
  was associated with the particular date.)
  Directly associated with this discussion are topics (3464), (3966),
  (4399), and (7290).
  Other related topics include (1233), (2315), (2943), (3009), (5313),
  (6559), (7499), and likely others.

answer written or last revised on ( 12-JAN-2003 )

» close window