× 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.



On Wed, 9 Jul 2003, John Cunha wrote:
>
> We receive files from a third party vendor which are tab delimited as
> shown below.

Hmmm.. I didn't get this sample.  Keep in mind that attachments don't
work on this mailing list.

> We need to move the contents (different record types) of this file into
> DDS external described files for each type.
>
> Does anyone know how to do this in a clean, fast and reliable way?

The non-RPG method would be the CPYFRMIMPF command.  But, I'm not going
to say much about that, since this is the RPG list and that would be
off-topic. :)

> I.e. not have to read the record byte by byte to remove the tabs from
> the records!

Lesse... you requirements are:

fast:   Don't read the record byte-by-byte, but read a chunk into a
        buffer.  That'll make a big difference in performance.
        Alternatively, use fopen/fgets to read a record at a time, and
        then parse the record.

reliable:  Don't use fscanf() or sscanf() to parse the record, since
        larger than usual data could cause an overflow and make it
        unreliable.  Aside from that, reliability is really based on
        how well you write code :)

clean:  Keep things clean by breaking them into logical procedures.
        i.e. don't have the parsing loop in your mainline, that'll
        make your code messy.   Reading until you get a tab is not
        a difficult thing to do, so I'm not really clear on why
        this is a big concern of yours...

Personally, I prefer using my own routines to parse files rather than
CPYFRMIMPF, I like having more control over the parsing, so I can make it
work exactly as I want it to.   However, if you really don't want to
search the record byte by byte, then maybe you should consider CPYFRMIMPF
instead of RPG.  I guess I don't understand what's wrong with reading
it byte-by-byte...

I've got a tutorial on stream files from RPG here:
http://www.scottklement.com/rpg/ifs.html

It doesn't go into fopen/fgets/fclose, etc, though.   If you post the
samples of how your file format works, I may be able to whip up some
sample code that shows how to deal with it...



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.