- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Indexed files and c++
Operating System - OpenVMS
1753784
Members
6779
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2008 04:40 PM
тАО05-28-2008 04:40 PM
Is there a way to open an indexed file in c++ similar to using HPbasic.
For example say we have a simple ddl defined in DDL:MAST.INC
----------------------------------------------
DDL:MAST.INC
----------------------------------------------
RECORD MAST_REC
VARIANT
CASE
STRING WHOLE=20
CASE
STRING KEY 0=4
CASE
STRING ACCT=4
STRING NA.ME=16
END VARIANT
END RECORD
After converting the data file with an fdl it would be opened in basic like this.
DECLARE LONG CONSTANT MAST.CHAN =22%
INCLUDE "DDL:MAST.INC"
MAP (MAST_MAP) MAST_REC MAST
OPEN MAST$DAT FOR INPUT AS FILE #MAST.CHAN, &
INDEXED, &
ACCESS READ, ALLOW MODIFY, &
MAP MAST_MAP, BUFFER 4%, &
PRIMARY MAST::KEY0
INPUT "Enter acct ";acct$
GET #MAST.CHAN, KEY #MAST::KEY0 EQ ACCT$
IF E%
THEN PRINT ERT$(E%)
EXIT PROGRAM
END IF
PRINT "ACCT= ";MAST::ACCT
PRINT "NAME= ";MAST::NA.ME
END PROGRAM
I have searched the web, but have not been able to find much on this. Any help would be much appreciated.
For example say we have a simple ddl defined in DDL:MAST.INC
----------------------------------------------
DDL:MAST.INC
----------------------------------------------
RECORD MAST_REC
VARIANT
CASE
STRING WHOLE=20
CASE
STRING KEY 0=4
CASE
STRING ACCT=4
STRING NA.ME=16
END VARIANT
END RECORD
After converting the data file with an fdl it would be opened in basic like this.
DECLARE LONG CONSTANT MAST.CHAN =22%
INCLUDE "DDL:MAST.INC"
MAP (MAST_MAP) MAST_REC MAST
OPEN MAST$DAT FOR INPUT AS FILE #MAST.CHAN, &
INDEXED, &
ACCESS READ, ALLOW MODIFY, &
MAP MAST_MAP, BUFFER 4%, &
PRIMARY MAST::KEY0
INPUT "Enter acct ";acct$
GET #MAST.CHAN, KEY #MAST::KEY0 EQ ACCT$
IF E%
THEN PRINT ERT$(E%)
EXIT PROGRAM
END IF
PRINT "ACCT= ";MAST::ACCT
PRINT "NAME= ";MAST::NA.ME
END PROGRAM
I have searched the web, but have not been able to find much on this. Any help would be much appreciated.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2008 04:42 PM
тАО05-28-2008 04:42 PM
Re: Indexed files and c++
Sorry about the formatting, is there a [code] [/code] tag i should be using on this forum ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2008 07:56 PM
тАО05-28-2008 07:56 PM
Solution
>> formating
There is a check-box "Retain format(spacing)."
>> Is there a way to open an indexed file in c++ similar to using HPbasic
Typically you would set up a FAB and RAB
and call RMS directly: SYS$OPEN, SYS$CONNECT, SYS$GET.
Chapter 2 in the C Userguide explains all about the details:
http://h71000.www7.hp.com/commercial/c/docs/5492profile_009.html#index_sec
You would have to create a C - layout for the record. Chapter 5 has a section on CDD and CDDL usage.
But it could be directly re-mapped as:
struct mast_rec {
union {
char whole[20];
char key[4];
struct {
char act[4];
char name[16];
} parts;
} parts_union;
} mast_rec;
Typically you would not need the union as much in C as in Basic.
C is perfectly happy with
your_rab.rab$l_kbf = mast_rec.acct;
your_rab.rab$b_ksz = sizeof ( mast_rec.acct );
No need to call it both 'key' and 'acct'
And this 'whole' just becomes
address: &mast_rec, with size = sizeof (struct mast_rec);
Enjoy!
Hein.
There is a check-box "Retain format(spacing)."
>> Is there a way to open an indexed file in c++ similar to using HPbasic
Typically you would set up a FAB and RAB
and call RMS directly: SYS$OPEN, SYS$CONNECT, SYS$GET.
Chapter 2 in the C Userguide explains all about the details:
http://h71000.www7.hp.com/commercial/c/docs/5492profile_009.html#index_sec
You would have to create a C - layout for the record. Chapter 5 has a section on CDD and CDDL usage.
But it could be directly re-mapped as:
struct mast_rec {
union {
char whole[20];
char key[4];
struct {
char act[4];
char name[16];
} parts;
} parts_union;
} mast_rec;
Typically you would not need the union as much in C as in Basic.
C is perfectly happy with
your_rab.rab$l_kbf = mast_rec.acct;
your_rab.rab$b_ksz = sizeof ( mast_rec.acct );
No need to call it both 'key' and 'acct'
And this 'whole' just becomes
address: &mast_rec, with size = sizeof (struct mast_rec);
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2008 08:19 PM
тАО05-28-2008 08:19 PM
Re: Indexed files and c++
It appears you are seeking to port or to interoperate with BASIC code and related files from within a (new or updated) C/C++ application. Okfine.
You'll probably become familiar with DUMP (or with local code to perform a dump) here, to see exactly what is written into various records, and you'll also get familiar with the padding within records within a C structure. (See the #pragma member_alignment, for instance.)
As for code, there's a full source example
http://64.223.189.234/labsnotes/newuser102.zip which has a callable library of RMS operations in C, and record-level operations specifically with indexed files, and declarations and maintenance of record definitions using SDL (if that's of interest), which in aggregate should get you going.
Stephen Hoffman
HoffmanLabs LLC
You'll probably become familiar with DUMP (or with local code to perform a dump) here, to see exactly what is written into various records, and you'll also get familiar with the padding within records within a C structure. (See the #pragma member_alignment, for instance.)
As for code, there's a full source example
http://64.223.189.234/labsnotes/newuser102.zip which has a callable library of RMS operations in C, and record-level operations specifically with indexed files, and declarations and maintenance of record definitions using SDL (if that's of interest), which in aggregate should get you going.
Stephen Hoffman
HoffmanLabs LLC
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP