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



What you needed to do was specify different flags on the two calls
to open() (or openstmf() in your case)


first call:       O_CREAT + O_TRUNC + O_RDWR + O_CODEPAGE
The idea is to create the file (or clear it) and assign it a codepage.
For this call, you also need to specify the codepage and the mode.

second call:      O_RDWR + O_TEXTDATA
The idea here is to open an already existing file (you created it
in the first call) in text data mode.

Of course, if you're only writing to the file, not also reading,
you'd want to use O_WRONLY instead of O_RDWR.

Is this making sense?




On Mon, 28 Oct 2002, Brad Stone wrote:

> Oh, I see.  I shouldn't have specifyed O_TEXTDATA on the
> first create, and only specified it on the second create.
> Correct?  (see code in response to Eric..)
>
> Man, I need a nap.  :)
>
> Brad
>
> On Mon, 28 Oct 2002 17:04:17 -0600 (CST)
>  Scott Klement <klemscot@klements.com> wrote:
> >
> > Are you creating the file with O_CREAT and at the same
> > time assigning
> > O_TEXTDATA and O_CODEPAGE?  If so, that's the problem.
> >
> > When you open a file with O_TEXTDATA it translates
> > whatever the codepage
> > on the file is...  however, if the file doesn't exist, no
> > code page has
> > been assigned, so no translation is done.  When you use
> > O_CODEPAGE, you
> > are assigning a code page...  OS/400 thinks that the data
> > you're writing
> > to that file will already be in that code page, and
> > that's why you're
> > assigning that.
> >
> > For example, if you were writing an HTTP client (since I
> > know yu've done
> > this) and you've asked the server for a codepage, you'd
> > tell the AS/400
> > that codepage.  You wouldn't want the data translated,
> > because you'd be
> > receiving it on the socket already in that page.
> > And, that's what OS/400 thinks is happening...
> >
> > The solution is pretty simple.   First create the file
> > with
> > O_CREAT & O_CODEPAGE, then close() it and open it again.
> > This time with
> > O_TEXTDATA.   Since the file already exists, and already
> > has a code page,
> > the system will automatically translate for you.
> >
> > Good Luck!
> >
> >
> > On Mon, 28 Oct 2002, Brad Stone wrote:
> >
> > > I am creating an IFS file with an RPG program.  I am
> > > specifying the file as text data, code page 819.
> > >
> > > If I use WRKLNK to view the file, it looks great.  If I
> > try
> > > and use FTP to download the file, it's all garbage on
> > my PC.
> > >
> > > can anyone explain why?  :)
> > >
> > > I'm having a little brain fry today...
> > >
> > > Brad
> >



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.