HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

VAX BASIC DOUBT

 
SOLVED
Go to solution
sreeraj
Occasional Advisor

VAX BASIC DOUBT

How to get file create,revision and modified date through XAB by using offset and through fields?
I would also like to know the structure of XAB
10 REPLIES
Joseph Huber_1
Honored Contributor

Re: VAX BASIC DOUBT

Are You kidding ? Did Your neighbour post the same question under the name vax_basic recentlty ?

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1100553

answers Your question, with a working example !
http://www.mpp.mpg.de/~huber
Robert Gezelter
Honored Contributor

Re: VAX BASIC DOUBT

sreeraj,

The XAB structure is documented in the RMS Manual, which is available from HP's OpenVMS www site at http://www.hp.com/go/openvms

The BASIC programmer's manual describes the VMS-specific interface information as being contained in SYS$LIBRARY:BASIC$STARLET.TLB, and also explains how to build record definitions for data structures (I would check, but I do not have BASIC loaded on any systems at the moment).

- Bob Gezelter, http://www.rlgsc.com
Hein van den Heuvel
Honored Contributor
Solution

Re: VAX BASIC DOUBT

Oh, I get it now.

This is the 3rd question in a related series. The prior questions are 'closed'.

Sreeraj, (thanks for using a real name instead of 'vax basic') you can just re-open (or not close) topics to continue for detailed question. That easier on all of us!

PLEASE look around in the ITRC Form some for usage rules and hints!
Notably:
http://forums1.itrc.hp.com/service/forums/helptips.do?#41


prior question...
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1100856

Which is a really continutation for:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1100553

I now expect the problem with the second question to be the 'trick' with the MAP I used to make the basic generic XAB overlay with the XABDAT to get easy access to the Length and Code fields. The proper solution involves a RECORD with UNION, but that's so tedious! If it was my box I would be much tempted to create an alternative XABDAT defintion with easily addressible COD and BLN instead of the silly mumbleFILLmubles.

>> I would also like to know the structure of XAB

Besides the documenations I urge you to SLOWLY and CAREFULLY study:
1) $ libr/extr=$xabdat/out=xabdat.mar sys$library:starlet.mlb

2) LIBR/EXTR=$XABDATDEF /OUT=XABDAT.BAS SYS$LIBRARY:BASIC$STARLET.TLB

3) LIBR/EXTR=$XABDEF /OUT=XAB.BAS SYS$LIBRARY:BASIC$STARLET.TLB

Hein van den Heuvel
HvdH Performance Consulting.
Hein van den Heuvel
Honored Contributor

Re: VAX BASIC DOUBT




And after you studied all that check out this rehash of my first example, now using the individual fields, not offset tricks.
Enjoy,
Hein.


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

CALL sys$asctim (0 BY VALUE, DATE_TIME, XABDAT::XAB$L_CDT0, 0 BY VALUE)
PRINT "Created:", DATE_TIME
CALL sys$asctim (0 BY VALUE, DATE_TIME, XAB::XAB$L_RDT0, 0 BY VALUE)
PRINT "Modifed:", DATE_TIME

GOTO 2

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


sreeraj
Occasional Advisor

Re: VAX BASIC DOUBT

hai all while using the attached file as subroutine there is a run time error.

where as using the same code with in the main program there will not be any error.

can you find a fix for the problem and also the reason for the error


thank you in advance..
Hein van den Heuvel
Honored Contributor

Re: VAX BASIC DOUBT


Read, re-read and re-read all replies I made. The answers is there, spelled out.

You'll need to learn VMS and It's BASIC better if you are going to call system routines.

The broken line is: DECLARE STRING EX_DATE_TIME

That's a DYNAMIC string.
It must be STATIC for use by $ASCTIM or at the very least it must be pre-sized.

:-(

Hein
John Gillings
Honored Contributor

Re: VAX BASIC DOUBT

sreeraj,

> I would also like to know the structure of XAB

Although it may be of intellectual interest to know how XABs and other RMS structures are layed out, it's of little practical interest in writing code. Indeed, it may even be a hindrence if you depend on internal details. In general, use whatever prebuilt language constructs are provided and limit yourself to just the fields of interest.

Start simple, and build up by making small changes to existing, working code. Trying to do everything from the start will be confusing and difficult to diagnose what's wrong.

For some languages, it's easier, shorter and clearer to code RMS stuff in MACRO32!
A crucible of informative mistakes
Hoff
Honored Contributor

Re: VAX BASIC DOUBT

>> IF L_STAT <> RMS$_NORMAL

The usual and typical test is for the low bit of the return status, and not a specific status until and unless you need a specific status. A generic success or failure test involves the low bit, and when the low bit is set, the call has worked. if you need a specific test against a function (usually an error, though there can be alternate successes) then a match against that can be made.

Put another way, the above test misses all of the potential successful status conditions that could conceivably be returned from the function -- save for one.


>> CALL SYS$ASCTIM ...

Testing the return condition from most any call that provides it is a good idea.

There exists a list of common coding errors over in the old Ask The Wizard area in topic (1661). That topic is a collected list of errors that I and other folks have made or have debugged over the years, consolidated down into a relatively small list. http://www.hp.com/go/openvms/wizard

The programming concepts manual is a good resource for this, as it introduces various of the expectations and assumptions of the OpenVMS interfaces and of OpenVMS programming.

The OpenVMS (and other product) manuals are available at http://www.hp.com/go/openvms/doc -- for the RMS calls and RMS data structures, the FAB, RAB and XAB stuff is documented in the RMS Routines Reference Manual.

In addition to John's comment, it's also potentially feasible to call into another language which can return the date and time values. C, for instance, has access to this data through the stat() calls.

Stephen Hoffman
HoffmanLabs

sreeraj
Occasional Advisor

Re: VAX BASIC DOUBT

i got a run time error ,Memeory management violation , when i put a print statement in my sub routine.

CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_REV_DATE, XAB::XAB$L_RDT0, 0 BY VALUE)
CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_CRT_DATE, XABDAT::XAB$L_CDT0, 0 BY VALUE)

! this print statement cause the problem
PRINT""
CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_BKUP_DATE , XABDAT::XAB$L_BDT0, 0 BY VALUE)
CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_EXP_DATE, XABDAT::XAB$L_EDT0, 0 BY VALUE)

please have a look at the follwing code.
What is wrong with this code.



*******MAIN PROGRAM********


EXTERNAL SUB GET_FILE_ATTRIBUTE ( STRING, &
STRING, &
STRING, &
STRING, &
STRING, &
LONG )
DECLARE STRING T_FILE_NAME, &
T_CREAT_DATE, &
T_REVIS_DATE, &
T_BAKUP_DATE, &
T_EXPIR_DATE

DECLARE LONG L_ERR

INPUT"ENTER FILE NAME : ";T_FILE_NAME
CALL GET_FILE_ATTRIBUTE (T_FILE_NAME, &
T_CREAT_DATE, &
T_EXPIR_DATE, &
T_REVIS_DATE, &
T_BAKUP_DATE,&
L_ERR )
IF L_ERR = 1 THEN
PRINT" FILE ERROR "
ELSE
! PRINT"CREATED DATE ; ";T_CREAT_DATE
! PRINT"REVISION DATE ; ";T_REVIS_DATE
! PRINT"EXPIRE DATE ; ";T_EXPIR_DATE
! PRINT"BACK UP DATE ; ";T_BAKUP_DATE
END IF

END




/*********************************** SUB ROUTINE ****************************************************************************/

****File_Att.bas****


SUB GET_FILE_ATTRIBUTE( STRING T_FILE_NAME,&
STRING T_CRT_DATE,&
STRING T_EXP_DATE,&
STRING T_REV_DATE,&
STRING T_BKUP_DATE,&
LONG L_ERR_STAT )
!
! EXTERNAL FUNCTIONS
!
EXTERNAL LONG FUNCTION SYS$OPEN(FABDEF)
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"


MAP (RMS_BLOCKS) XABDATDEF XABDAT, RABDEF RAB, FABDEF FAB, &
STRING NAME_BUFFER = 80
MAP (RMS_BLOCKS) XABDEF XAB

RECORD FILE_ATT
STRING T_CRT_DATE = 11
STRING T_EXP_DATE = 11
STRING T_REV_DATE = 11
STRING T_BKUP_DATE = 11
END RECORD
! this record is created because the function a SYS$ASCTIM require strings of fixed lenght

DECLARE INTEGER L_STAT, L_DATE_OFFSET, L_DATE_POINTER
DECLARE STRING rdat
DECLARE FILE_ATT F_DATE_ATT

NAME_BUFFER = T_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(T_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

L_STAT = SYS$OPEN(FAB) !OPEN THE FILE

IF L_STAT <> RMS$_NORMAL THEN
L_ERR_STAT=1
PRINT "ERROR IN OPENING FILE"
GOTO TERMINATE
END IF

CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_REV_DATE, XAB::XAB$L_RDT0, 0 BY VALUE)
CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_CRT_DATE, XABDAT::XAB$L_CDT0, 0 BY VALUE)

! this print statement cause the problem
PRINT""
CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_BKUP_DATE , XABDAT::XAB$L_BDT0, 0 BY VALUE)
CALL SYS$ASCTIM (0 BY VALUE, F_DATE_ATT::T_EXP_DATE, XABDAT::XAB$L_EDT0, 0 BY VALUE)

PRINT" REVISION DATE :";F_DATE_ATT::T_REV_DATE
PRINT" CAREATION DATE :";F_DATE_ATT::T_CRT_DATE
PRINT" BACKUP DATE :";F_DATE_ATT::T_BKUP_DATE
PRINT" EXPIRE DATE :";F_DATE_ATT::T_EXP_DATE

! T_CRT_DATE = F_DATE_ATT::T_CRT_DATE
! T_EXP_DATE = F_DATE_ATT::T_EXP_DATE
! T_REV_DATE = F_DATE_ATT::T_REV_DATE
! T_BKUP_DATE = F_DATE_ATT::T_BKUP_DATE

TERMINATE:
END SUB



Thanks in advance

Hein van den Heuvel
Honored Contributor

Re: VAX BASIC DOUBT


Got it...

I tend to create my basic with: OPTION CONSTANT TYPE = INTEGER

But left that for this example.
So those "0 by value" turned into floating point stuff leaving the real argument in the registers as undefined (actually R16 = 65537 from the RMS$_SUC return, that being to only possible succesfull return from SYS$OPEN :^).

Either use the OPTION, or pass "0% BY VALUE"

Also... if you just want the date, then the documentation SUGGESTS that you should really pass a 12 byte string to SYS$ASCTIM, allowing for the final blank.

Hein.