× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Dynamic reading of a file
  • From: Martin Rowe <martin@xxxxxxxxxx>
  • Date: Mon, 28 May 2001 16:59:30 +0100
  • Organization: Jamaro

On Monday 28 May 2001 10:02, Madhusudhana Perumal Iyah Guruswamy suresh 
wrote:
> Hi
>
> Can anyone give me some information of reading a file dynamically.
>
> The problem is, I know the file to read only at runtime and I have to
> read the file and display  the data for processing. Is there any way to
> read a file like this.
>
> Any info on this is appreciated.
>
> Thanks.
>
>
> Suresh.

Hi Suresh

If your file has the same layout, but a different library or name, then 
you can do a compile against the known file and an OVRDBF to the target 
file at run time, before opening the file. If you don't even know the 
layout in advance then I would use a program described file with a single 
field, big enough to handle the longest record length your runtime file 
is likely to have. Override to the desired file at runtime and use the 
system APIs to get the file layout and field properties, then read in 
each record, substringing each 'field' out of the big field. For 
non-string fields you can map them onto a data structure that has a 
character field overlaying a field of the right type (with maximum size). 
You can then format this data as required for your display (concatenating 
the formatted strings into a single field for subfile display).

I have an example of this technique on my site (see .sig below) where I 
create a comma delimited flat file from a DB2/400 file chosen at runtime. 
In this case all character, packed, zoned, binary, date/time & float[1] 
values get formatted into a character representation so it should be easy 
to load them into a subfile instead. Go to the Extras page (from the main 
page, Extras section) and look for CRTCSVDTA.

Regards, Martin 

[1] Not too sure if it's handling these right as I've never come across 
them until writing CRTCSVDTA and setting some up files to test it with. 
If float field are likely to crop up in your database, you may need to do 
some more work ;-)
-- 
martin@dbg400.net / jamaro@firstlinux.net
http://www.dbg400.net  DBG/400 - DataBase Generation utilities 
Open Source test environment tools for the AS/400 / iSeries and 
miscellaneous database & spooled file management commands.
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.