This article written and copyright 2012 by Will Johnson, wjhonson@aol.com
Universe has several files that are usually created as OS directories (Type 1 or 19 files). The records in these files, have special OS-set properties, which hashed-Universe files do not enjoy. Among these extra special properties, are the date created and the date modified. Until you read this article, you've been popping out to the OS level (Unix or Windows) to query on these dates. I'm going to show you how you can query them, from inside Universe.
The BASIC command STATUS will, for a given file, return these dates, but only works on file variables, not records. However, the trick here is realizing, that if you build the full path to the record in the directory, you can then open that path as a file using the OPENSEQ command, which will give you the file pointer you then need to hand off to STATUS.
Here is the Subroutine you need to write, notice that we are NOT specifying which cell of the array to return, that will be handled by the DICT item we'll create next.
SUBROUTINE FILESTATUS.SUBR(RESULT,CELL)
* Return elements of the STATUS array for one item to an I-desc
* Written Aug 2012 by Will Johnson
* based on a comment by Charles Stevenson on LinkedIn
* Get the directory file path, then append the particular item id
* That's whose STATUS we really want
*
$INCLUDE SYSCOM INC.STATUS
OPEN @FILENAME TO FILE ELSE RESULT = 'ERROR' ; RETURN
STATUS FILEARRAY FROM FILE THEN
PATH = FILEARRAY<27> ; *This is the os Path to this file
PATH = PATH:'\':@ID
OPENSEQ PATH TO FILE ELSE RESULT = 'ERROR' ; RETURN
STATUS FILEARRAY FROM FILE THEN
IF (CELL = '') OR (CELL = 0) THEN
RESULT = FILEARRAY
END ELSE RESULT = FILEARRAY<CELL>; * Your dict entry specifies the cell
END ELSE RESULT = 'ERROR'
END ELSE RESULT = 'ERROR'
RETURN
*
Remember to Globally catalog this routine, otherwise you will not be able to use it in the I-descriptor we create next. We globally catalog the routine by doing this
CATALOG MYBP *FILESTATUS.SUBR FILESTATUS.SUBR
This makes the entry in the GLOBAL.CATDIR file be *FILESTATUS.SUBR
Notice that this subroutine does not know what the file, record, or array cell is which you're going to ask it to use and return. So it can truly be used in any Type 1 file, on any of its records, to return any of the array cells that the Status function returns.
So to specify that we want to see the Create Date in the &HOLD& file, we would next create a new I-descriptor in the Dictionary of the &HOLD& file, and tell it to call this subroutine, and return cell 18, which is the Create Date.
ED DICT &HOLD& FILE.CREATE.DATE
001 I
002 SUBR('*FILESTATUS.SUBR',18)
003 D2-
004 Create date
005 8R
006 S
.FI
"FILE.CREATE.DATE" filed in file "DICT &HOLD&"
Now we test it.
LIST &HOLD& FILE.CREATE.DATE
&HOLD&................. Create date
WILLS.RPT1 01-01-2012
WILLS.RPT2 01-14-2012
OTHER.STUFF 07-15-2011
Voila. It works.