1828378 Members
3446 Online
109977 Solutions
New Discussion

File Attribute

 
KiranSharma
Occasional Contributor

File Attribute

Is there any function in VAX Basic to get file attribute like created date, modified date etc.

Or how is it possible to get file attribute like created date, modified date etc with out using lexical function F$FILE_ATTRIBUTES

Please help me..
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: File Attribute

One can do this using VMS system services in
any language, including BASIC. For example
code in C, you could look at the source for
the Info-ZIP Zip program ([.vms]vmsmunch.c:
VMSmunch()).

http://www.info-zip.org/
http://www.info-zip.org/Zip.html
http://sourceforge.net/project/showfiles.php?group_id=118012

However, the fact that you're asking the
question suggests that you may be unfamiliar
with VMS system services, so some struggling
may be expected.

A quick Google search for:

basic qio OR qiow IO$_ACCESS

did find this potentially helpful example
showing how to do some similar things.

http://h18000.www1.hp.com/support/asktima/appl_tools/009688F7-F95FC060-1C0097.html
labadie_1
Honored Contributor

Re: File Attribute

The create date is with CDT, example

wr sys$output f$file("login.com","cdt")
21-JUL-2006 09:12:13.42

see th help with
$ help lexical f$file arg
Hein van den Heuvel
Honored Contributor

Re: File Attribute

There is no function directly in vax-basic.

Are you sure you are talking VAX, not Alpha?
What version, what box? what VMS versions?

The data most basically is avaiable from the file system through QIO ans Steven suggests.

However, you may prefer the RMS access methods, where the dates will be mdae available in the XABDAT (or XABRDT) structure.

There you have three basic (sic) choices:

1) Use the BASIC language OPEN statement to have it create a FAB and RAB and provide a USEROPEN in which an XABDAT is hooked up.
Example: http://h18000.www1.hp.com/support/asktima/appl_tools/00928923-BAC83760-1C0069.html

2) Allocate your own FAB and XAB and call SYS$OPEN directory form Basic

Incolplete examples:

http://h71000.www7.hp.com/freeware/freeware60/rms_tools/bonus/indexed_file_patch.bas

http://h71000.www7.hp.com/wizard/wiz_4613.html

3) The above, but using C or Macro to do teh dirty work and just call a service routine from basic.



Good luck,

Hein.


Hein van den Heuvel
Honored Contributor

Re: File Attribute

One of my links shows an ugly
inside. Sorry.


To make up here is a complete example.

Sample usage:

$ mcr sys$login:date_test login.com
RDT 30-JAN-2007 22:18:15.99
CDT 6-JUL-2006 13:04:50.47
EDT 17-NOV-1858 00:00:00.00
BDT 11-JAN-2007 05:00:26.55

$ type date_test.bas
1 OPTION TYPE = EXPLICIT, CONSTANT TYPE = INTEGER
!
! Get_file_dates.bas Hein van den Heuvel, Feb-2007
! Based on indexed_file_patch.bas example.
!
On error go to hell!

EXTERNAL LONG FUNCTION SYS$OPEN(FABDEF), LIB$GET_FOREIGN(STRING,STRING)
EXTERNAL LONG CONSTANT RMS$_NORMAL
%INCLUDE "$FABDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB"
%INCLUDE "$RABDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB"
%INCLUDE "$XABDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB"
%INCLUDE "$XABDATDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB"

DECLARE STRING FILE_NAME, TXT
DECLARE INTEGER STAT, DATE_OFFSET, DATE_POINTER
MAP (RMS_BLOCKS) XABDATDEF XABDAT, RABDEF RAB, FABDEF FAB, &
STRING DATE_TIME = 23, NAME_BUFFER = 80
MAP (RMS_BLOCKS) XABDEF XAB ! Yuck

STAT = LIB$GET_FOREIGN (FILE_NAME, 'File name: ')

NAME_BUFFER = FILE_NAME !Move into static string for LOC().
FAB::FAB$B_BID = FAB$C_BID !Make this a real FAB
FAB::FAB$B_BLN = FAB$C_BLN !Make this a real FAB
FAB::FAB$L_FNA = LOC(NAME_BUFFER) !Put Address of name_buf in Fab
FAB::FAB$B_FNS = LEN(FILE_NAME) !Put Lenght of file_name in Fab
FAB::FAB$B_FAC = FAB$M_GET !READ access
FAB::FAB$B_SHR = FAB$M_UPI !No locking what so ever needed
RAB::RAB$L_FAB = LOC(FAB) !Put Address of Fab in Rab
FAB::FAB$L_XAB = LOC(XAB) !Put Address of Xab in Fab
XAB::XAB$B_COD = XAB$C_DAT !Make this a DAT XAB
XAB::XAB$B_BLN = XAB$C_DATLEN !Make this a DAT XAB

STAT = SYS$OPEN(FAB) !Open the file
CALL sys$exit(STAT BY VALUE) IF STAT <> RMS$_NORMAL

! Like to get OFFSETs, rather than fiels for the dates. Cheat:
! $ pipe libr/out=sys$output:/extr=$xab*def -
! SYS$LIBRARY:STARLET.mlb | search sys$pipe: t_overlay

DATA 12,"RDT",20,"CDT",28,"EDT",36,"BDT",0
READ DATE_OFFSET
WHILE (DATE_OFFSET)
DATE_POINTER = LOC(XABDAT) + DATE_OFFSET
CALL sys$asctim (0 BY VALUE, DATE_TIME, &
DATE_POINTER BY VALUE, 0 BY VALUE)
READ TXT
PRINT TXT, DATE_TIME
READ DATE_OFFSET
NEXT
GOTO 2

HELL: PRINT ERT$(ERR) UNLESS ERR = 11
RESUME 2
2 END

KiranSharma
Occasional Contributor

Re: File Attribute

thank you