Operating System - OpenVMS
1752788 Members
6278 Online
108789 Solutions
New Discussion юеВ

How to populate a local variable with the value from a field present in a file.

 
panneer
Occasional Contributor

How to populate a local variable with the value from a field present in a file.

I have a file X having a numeric variable NUM.
I need the value of NUM to be stored in another local variable .
READY X SHARED
FIND ALL X With NUM=1
[1 record found]
I want this value to be stored in a local variable.
Kindly provide a solution.

Thanks.
3 REPLIES 3
Bart Zorn_1
Trusted Contributor

Re: How to populate a local variable with the value from a field present in a file.

Hello panneer,

Can you provide some information about the environment you are talking about?

Which Operating System? If a Database is involved, what type of Database?

Thanks,

Bart
panneer
Occasional Contributor

Re: How to populate a local variable with the value from a field present in a file.

Its a DTR code and Operating system is OPEN VMS.

READY X SHARED
FIND ALL X With NUM=1
[1 record found]
I want this value(in NUM) to be stored in a local variable.
Kindly provide a solution.
DECxchange
Regular Advisor

Re: How to populate a local variable with the value from a field present in a file.

Hello,
What programming language are you using to execute these Datatrieve (DTR) commands in OpenVMS? Are you doing this in DCL, BASIC, FORTRAN, or what? Also, do you know what verison of VMS you are on? VAX or Alpha?

I used to do some Datatrieve programming on a MicroVAX some eighteen years ago. I used Fortran to call Datatrieve commands.

Basically, without giving you a complete solution, first you need to setup a RECORD structure, if you're using a programming language, such as FORTRAN. This record structure must match your database layout, or match the ad hoc query from Datatrieve. Your database layout is probably done in CDD (Common Data Dictionary. Then you have to use Datatrieve function calls (something like CALL DTR$CONTEXT(), CALL DTR$FIND()) that sets up a context that will allow you to store the datatrieve output from the FIND command, into your programming language data record structure.

For (FORTRAN) example,

STRUCTURE /dtr_structure/
UNION
MAP
BYTE datatrieve_data(nnnn)
END MAP
MAP
CHARACTER*(nnnn) variable1
INTEGER variable2
REAL variable3
CHARACTER*(mmm) variable4
...
...
END MAP
END UNION
EMD STRUCTURE
RECORD /dtr_structure/ dtr_record

CALL DTR$CONTEXT(dtr_conext)
CALL DTR$FIND(dtr_context,dtr_command,dtr_record)

Or something like that. I don't remember the exact syntax. You might have manuals that explain how to program in DTR and what the correct syntax of DTR function calls are.

Tell you what, if this is the direction you think you need to go, I will try to find some code I have on backup tapes and see if I can find something that will help you out.

DECxchange