Operating System - OpenVMS
1755898 Members
3992 Online
108839 Solutions
New Discussion юеВ

Re: File specification at run-time in MACRO-32

 
SOLVED
Go to solution
yaron1
Advisor

File specification at run-time in MACRO-32

Hi,

I need a MACRO-32 procedure to be able to work with a different file upon each call to the procedure. All files have the same characteristics. If I supply the file specification to the FNM parameter in the $FAB control block at assembly time that forces me to work with the same file.
1. Do I need to give values at run time to the FAB$L_FNA and FAB$B_FNS fields?
2. If 1 is wrong, do I need the $NAM control block?

Any example would be great.

Thanks for the answers.
9 REPLIES 9
Heinz W Genhart
Honored Contributor

Re: File specification at run-time in MACRO-32

Hi yaron1

why not using LIB$GET_FOREIGN.

Here a small fragment of a program using Lib$Get_foreign

EPID_DESC: ; Descriptor for ascii PID
.ascid / / ; 15 characters
.align long

PID_PROMPT: ; Prompt to use for PID
.ascid -_Target PID: -


pushab EPID_DESC ; Where to return PID text
pushab PID_PROMPT ; Prompt to use for input
pushab EPID_DESC ; Returned resultant length
calls #3, g^LIB$GET_FOREIGN ; Get the PID text
BLBC R0,1000$ ; Check for errors


Regards

Geni
Robert Gezelter
Honored Contributor

Re: File specification at run-time in MACRO-32

Yaron,

Heinz has already noted that, depending on what one needs to do with the file, the LIB$ routines may be an easier shortcut than using RMS directly.

RMS can certainly be used directly, and filename strings can be specified in a number of ways. Generally, they are passed via RMS user mode data structures using the information extracted from a string descriptor, to wit, the address and length of the string (note, if you are internally passing around "C" format zero terminated strings, it is straightforward to compute the length of the string using the "C" library.

The RMS data structure manipulations are fully (if somewhat exhaustively) documented in the RMS manual, which is available on the OpenVMS WWW site at http://www.hp.com/go/openvms

I have used these descriptions many times. As noted, the prose is detailed, but usable.

- Bob Gezelter, http://www.rlgsc.com
Hoff
Honored Contributor

Re: File specification at run-time in MACRO-32

Both 1 and 2 work fine. Using the NAML works, too.

There are many different ways to code this, whether using Macro32 and RMS, using Macro32 and RTL I/O routines (lib$get_foreign for the user, lib$find_file et al for file and directory searches, etc), using Macro32 and other languages (C, COBOL, Bliss, pretty much any language you're comfortable using), using logical names and/or the primary/secondary/tertiary filenames to pass around the specifications, and otherwise.

If you're not comfortable coding in Macro32, it may be most advantageous to have somebody code this for you. (The assumed and direct implementation case is under an hour of coding, including building a test harness.) Alternatively, there are folks around here in ITRC that can provide Macro32 training.

As for example source code, the ITRC James search engine (look for the "Compaq" search tool at top of the http://www.itrc.hp.com web site), and Google is often your BFF here, too. (The Google site: keyword restricts the search to specific hosts, too, and site:mvb.saic.com is often a good choice for this case and this question.) The OpenVMS Frequently Asked Questions (FAQ) http://www.hoffmanlabs.com/vmsfaq also has information on where to find source code examples for OpenVMS.

Stephen Hoffman
HoffmanLabs LLC
yaron1
Advisor

Re: File specification at run-time in MACRO-32

Hi,

Thanks for the answers. This MACRO-32 procedure is to be called from another MACRO-32 program. Each call to work on a different file. I use MACRO-32 because I have no high level language compiler available. I├в m used to Cobol.
So if my $FAB control block looks something like that (note the absence of FNM):
P1FAB: $FAB SHR = ,-
ORG = IDX

So, assuming that somewhere in the program I have:

FILE1: .ASCIC /FILE1.DAT/ ; file name, first byte is the count

I can set at run time the FAB$L_FNA and FAB$B_FNS fields by referring to them by their offset:

MOVL #FILE1+1,P1FAB+FAB$L_FNA ; (file specification string address)
MOVB FILE1,P1FAB+FAB$B_FNS ; (the file specification string size in bytes)


Thanks for the answers, have a nice weekend.

Yaron.
Hein van den Heuvel
Honored Contributor
Solution

Re: File specification at run-time in MACRO-32

I just use the $FAB control block optional parameters for very basic, static params.
DNM, FAC and SHR are certainky good candidates.
XAB and NAM could be.

The rest, such as FNA/FNS, ALQ for created files, is typically filled in at runtime.

Just move fresh values into fab+fab$b_fns and so on (or) fab$b_fns(fab) where fab is a register holding a fab address.

for a macro example:
http://mvb.saic.com/freeware/freewarev50/rms_tools/src/zap.mar

But as Hoff implies... why macro?
Calling RMS from C is much more convenient

examples:
http://mvb.saic.com/freeware/freewarev40/rms_tools/src/show_roots.c
http://mvb.saic.com/freeware/freewarev40/rms_tools/src/copyfile.c


Enjoy!
Hein.


Hein van den Heuvel
Honored Contributor

Re: File specification at run-time in MACRO-32

Didn't see your reply...

>> MOVL #FILE1+1,P1FAB+FAB$L_FNA ; (file specification string address)
>

Typically I prefer MOVAB FILE1+1,P1FAB+FAB$L_FNA

> MOVB FILE1,P1FAB+FAB$B_FNS ; (the file specification string size in bytes)

Fine, but is the name not passed as an argument?

>> ORG = IDX

Fine... but only useful for SYS$CREATE, and you really should not be creating Indexed files on the file with static structures + macro + sys$create. Please consider calling FDL$CREATE an check out FDL$PARSE, but that's probably not useful.
fab$b_org is OUTPUT for SYS$OPEN.

hth,
Hein.






Robert Gezelter
Honored Contributor

Re: File specification at run-time in MACRO-32

Yaron,

Okay, generally you are correct, with some suggestions concerning MACRO-32:

MOVL #FILE1+1,P1FAB+FAB$L_FNA ; (file specification string address)
MOVB FILE1,P1FAB+FAB$B_FNS ; (the file specification string size in bytes)

Instead, as someone who has been working with MACRO-32 since VAX/VMS 1.0, I would recommend the use of MOVAL instead of a MOVL #xxx (which was the way it was done in MACRO-11):

MOVAL FILE1+1,P1FAB+FAB$L_FNA ; (file specification string address)

The MOVAL instruction creates a execution time computation of the address, which can be treated as a Read-only page. The MOVL with a literal requires processing by the LINKER and image activator, and will not result in a Read-only page.

If you are using COBOL or other high level language, I would pass the filename by descriptor and deconstruct the descriptor directly into the FAB. I will let Hein correct me if my memory is incorrect, but I do not believe that the filename is used after the OPEN returns control to the user (I am in a place that it is inconvenient to access the manual, so I cannot check the manual at this instant).

- Bob Gezelter, http://www.rlgsc.com
yaron1
Advisor

Re: File specification at run-time in MACRO-32

Hi,

The name of the file isnt passed as an argument. The argument is only the key of a record in one of 10 files. The key also tells what file to open out of the 10. All 10 files can be defined in the procedure with the 10 .ASCIC directives.
Im not creating the files, just read them by key. Seems that historically someone split 1 enormous file into 10 different files to scatter them on different disks.

Thanks for the answers.

Yaron.
Hoff
Honored Contributor

Re: File specification at run-time in MACRO-32

Your phrasing implies the need for ten files is not a requirement any more. If so, fire up the DCL command MERGE and make the ten files one, and move onto the next issue.