1748067 Members
5623 Online
108758 Solutions
New Discussion юеВ

Re: COBOL and XAB

 
SOLVED
Go to solution
Hein van den Heuvel
Honored Contributor

Re: COBOL and XAB

For yucks I typed in a MACRO subroutine. Compiled and linked in one. Yeah.. I can still do it :-)

Hein

---------- my_get_cdt.mar --------
$FABDEF
.psect data,noexe,wrt
xabdat: $xabdat
.psect code,exe,nowrt
.entry my_get_cdt, 0
CALLS #0, G^DCOB$RMS_CURRENT_FAB ; pick up FAB address
MOVL R0, R8
MOVL FAB$L_XAB(r8), R2 ; Save old contents
MOVAL xabdat, FAB$L_XAB(r8) ; Insert our XAB
PUSHL r8
CALLS #1, G^SYS$DISPLAY ; Please
BLBC R0, 10$ ; Problem?
PUSHL #0 ; Time and Date
PUSHAL xabdat + XAB$Q_CDT ; RMS provided Creation Date
PUSHL 4(ap) ; Caller provided Ascci time buffer
PUSHL #0 ; No return length
CALLS #4, G^SYS$ASCTIM
MOVL R2, FAB$L_XAB(r8) ; Restore as found
10$: RET
.end

----------- Sample cobol caller ----------------

OPEN I-O TEST_FILE.
IF FILE_STATUS NOT = "00" THEN
DISPLAY "ERROR: TEST FILE OPEN ERROR, STATUS: ", FILE_STATUS
STOP RUN
END-IF.

CALL "my_get_cdt" USING BY DESCRIPTOR CDT_TIME GIVING rtn_status.
IF rtn_status IS FAILURE CALL "sys$exit" USING BY VALUE rtn_status.

DISPLAY "Create Date : ", CDT_TIME.
CLOSE TEST_FILE.
STOP RUN.


Mick O'Brien
Advisor

Re: COBOL and XAB

Hein,

Maybe this is a silly question but is there any way of getting the file creation date without opening the file - I'm just s trifle (raspberry) worried that the date may not be available if the file is already open (for exclusive access) by another process?

Regards
Mick
(PS - I'm happy you still have it. Do you know if it's contagious?)
Hein van den Heuvel
Honored Contributor

Re: COBOL and XAB

Yes, Macro is contagious. It takes a good bit of exposure to catch it, but once infected it's hard to shake. :-)

>> worried that the date may not be available if the file is already open

That's a very valid concern.
This is the same problem say F$FILE (filename,"CDT") has.

DIRECTORY/DATE=CREATE does NOT have that problem. It uses QIO access, does not open the file, and only requires the right to look at the file.

I have some examples for that (NOT using Cobol :-), some on the RMS_TOOLS directory under VMS Freeware, overdue for refresh.

But now we have to ask 'what problem are you really trying to solve'.

And without waiting for the answer, but assuming it is a silly management request, how about spawning DIR/DATE from COBOL and just tell them you'll need a bigger box if they really want to have this done?
:-)

Cheers,
Hein

Note 1 : I'm waiting for my flight home in the lounge for 'special people' in DTW, not feeing like 'real' work. So I had an hour or two to burn.

Note 2: Forgot the 'retain formatting' checkmark on the Macro reply. Sorry. Source attached as .TXT to make up for that.





Mick O'Brien
Advisor

Re: COBOL and XAB

Hein,

What I'm trying to do is capture the creation date of a log file whilst it is still open hence my questions. I have found example COBOL code that calls a macro to get the file fid and then makes calls to sys$qiow to get creation date, however as the GETFID macro still opens the file its just not quite right. Could you let me have details of programs that user ONLY sys$qiow (i.e. no file opens) to get creation date?

Thanks,
Mick

Richard J Maher
Trusted Contributor

Re: COBOL and XAB

Hi Ungrateful,

Guess there's nothing quite as tragic as unrequited love - I'll try and soldier on :-)

IIRC GETFID was only needed to get the FID/DID so that the $QIO IO$_ACPCONTROL (or io$_access) could use it to do the directory lookup?

If I'm also not mistaken sys$parse outputs the File ID and Directory ID without openong the file (or maybe even has a channel that can be re-used?) See attached for an example of $parse_s and other stuff.

Either way, my money's on your requirement of "creation date without having to open the file" being doable. (But I'm also guessing that detailed spec is worth about one point, so hold out for someone to come and play the aeroplane game. Open wide, boosh, woosh :-)

Maybe if you posted your current FIB definition and $qio code it might speed things up a little bit?

Cheers Richard Maher

PS. Bougainvillia: 1 People with skin: 0

PPS. Bojan great to see you're still around! (as it is Hein) If you get a few minutes and think you might know why FF3 is giving me "too much recursion" please look at:
http://groups.google.com/group/comp.lang.javascript/msg/43b32679ec125b17
Chrome is fine! FF2 is Fine! IE9 craps out after a while in the "innerHTML ="
Mick O'Brien
Advisor

Re: COBOL and XAB

As Roy Orbison sang...

"Only the lonely (dum-dum-dum-dumdy-doo-wah)
Know the way I feel tonight
(ooh-yay-yay-yay-yeah)
Only the lonely (dum-dum-dum-dumdy-doo-wah)
Know this feelin├в ain├в t right
(dum-dum-dum-dumdy-doo-wah)"

I think that last line's for you!

Anyways I have attached the code for you to view (note your name on GETFID.CBL)

I have not tried to run the attached .txt as a .com but should not be too many problems. The 'bit' that needs changing is get_creation_date.cbl where a call to GETFID is made.

Any help appreciated.
Richard J Maher
Trusted Contributor

Re: COBOL and XAB

Hi Mick,

Just had a look at: -
http://h71000.www7.hp.com/doc/731final/4523/4523pro_030.html#parse_service_routine

And saw this: -
NAM$W_FID 1 File identification (zeroed).

I have to say that "zeroed" bit at the end is a bit discouraging :-) Anyway I've downloaded your example code and will get back if I have anything useful to say.

Cheers Richard Maher

PS. The Big O eh. Best comeback since Lazarus and then he drops dead. There's a moral in there somewhere.
Richard J Maher
Trusted Contributor

Re: COBOL and XAB

Me again,

The bad news is RMS looks next to useless in this case (Hein "Mr RMS" Van den Heuvel may prove me wrong)

The good news is I started hacking away at my DIR_WATCH.COM routine (why this has never been included in VMS escapes me!) and I've come up with something that appears to work even on open files. (i.e. no additional "open" required, just a dir lookup)

As with my UWSS, this code does an io$_access on the name and then gets the FID from the FIB. (RMS still being used to get the DID to pass to the $QIO)

Anyway it seems to work, but if I stuff around a bit more I'm sure I can get the creation date directly and save your code the: -

lib$find_file
get directory
$assign
dickie getfid
$qio
$dassgn
etc

Hopefully more later, but in the meantime here's the documentation to go with my DIR_WATCH UWSSs. They really are quite clever and the code is being re-used here so could aid in understanding?

Cheers Richard Maher

PS. Don't worry, all user-mode code in the new stuff.
Hein van den Heuvel
Honored Contributor

Re: COBOL and XAB

Richard, most true artist are only recognized when it's way too late. You know that. You will we redeemed. Eventually. Nice work on the directory watch. Looks neat.


Mick, check out the attached. It does what you want with a cute 'hack' exploiting the fact that the LIB$FIND_FILE context is in fact... drum roll... a FAB.
And a nice FAB at that, as it has a hooked up and populated NAM upon success.
So stuff the Cobol IO and go naked.
Not to worry. This has worked for 20+ years, and there's no-one left to break it.

fwiw, I pretty much replaced the getfid with an OTS$MOVE3 to de-reference the NAM from the FAB. Hardcoded ATR$ stuff to make kitting easier. This values can't be changed. They are baked in to too many programs.
And added a sanity check on the QIO IOSB

Enjoy.
Hein

SMOP to pick up the full file name from the RSA (Resultant File Name String Address) or indeed why not from the lib$find_file return.
Richard J Maher
Trusted Contributor

Re: COBOL and XAB

Hi Mick,

I'd go with Hein's purely as it is fiendishly clever (although I contend that mine is demonstrable "better" :-)

The lack of Macro's probably also a maintenance bonus for some. Anyway OTY. . .

Cheers Richard Maher