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



Scott:

Thanks, that's exactly what the problem was.  I was using O_TEXTDATA for the
first but not for the second.

Dave

-----Original Message-----
From: Scott Klement [mailto:klemscot@xxxxxxxxxxxx]
Sent: Thursday, February 27, 2003 1:35 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Embedding an IFS file inside another IFS file



Your method should work... I'm doing similar things in some of my
projects, and I haven't had any problems.

You say "it appears as garbage"... that sure SOUNDS like a codepage issue.
Make sure that BOTH files have the correct codepage assigned to them
when they're created.   Make sure that they're BOTH opened with
O_TEXTDATA.

My thinking is that what you're doing is opening the second file without
O_TEXTDATA, thinking that it's already in ASCII.    The problem is,
O_TEXTDATA will force the data to be converted from EBCDIC to ASCII, and
if it's already ASCII, that'll give you garbage.

So, you either want to use O_TEXTDATA for BOTH files, or for neither...
If you are using O_TEXTDATA, you should be able to display the contents of
the variables from your READ/WRITE statements using STRDBG and see that
the data being written isn't garbage.

Good Luck!

On Thu, 27 Feb 2003, Leland, David wrote:

> I am attempting to create an IFS text file which has the contents of
another
> IFS text file embedded somewhere in the middle of it.  I'm attempting to
do
> this in an RPG program using the read() and write() API's.  Basically,
I'm:
> 1) creating the first file (using an open() with O_CREAT)
> 2) writing some text to it
> 3) opening the second file
> 4) reading it
> 5) writing the contents of the second to the first
> 6) closing the second file
> 7) writing some more text to the first file
> 8) closing the first file
>
> Unfortunately, this is not working the way I'd hoped.  The contents of the
> second IFS file appear as garbage in my first file even though both are
> ASCII files.  In my RPG program, I open the first file as follows:
> Eval      FileDesc = open(%ADDR(FullName)
>             : O_CREAT + O_WRONLY + O_TRUNC +
>               O_CODEPAGE
>             : S_IRWXU + S_IROTH
>             : AsciiCodePage)
>
> Then I close it:
> Eval      ReturnInt = close(FileDesc)
>
> Then I reopen it.
> Eval      FileDesc = open(%ADDR(FullName)
>             : O_TEXTDATA + O_RDWR)
>
> Then I write some text to it.  This is the technique I always use and it's
> worked fine for other things but I can't figure out how to get the
contents
> of the first to not be garbage.  I don't think it has anything to do with
> codepages but am not sure.
>

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.