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



My bad, When I changed pgm from open/create/close/open I left the close in so I was writing to a closed file

Surprised I did not get an error, when attempting to write to closed file??

Obviously I am new to this writing directly to the IFS put it does seem straight forward once you figure our how it works


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of John Allen
Sent: Friday, June 01, 2012 2:31 PM
To: 'RPG programming on the IBM i / System i'
Subject: RE: Attempting to write to IFS andmissing turkish characters

Correct and this is what I am doing

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Leif Guldbrand
Sent: Friday, June 01, 2012 12:04 PM
To: RPG programming on the IBM i / System i
Subject: Re: Attempting to write to IFS andmissing turkish characters

John...

IIRC at V5R1 you first need to create the file and close it.
Next you open it and write data to it.

This isn't needed at V5R2 and up !!

HTH :-)

Leif
----- Original Message -----
From: "John Allen" <jallen@xxxxxxxxxxx>
To: "'RPG programming on the IBM i / System i'" <rpg400-l@xxxxxxxxxxxx>
Sent: Friday, June 01, 2012 4:35 PM
Subject: RE: Attempting to write to IFS andmissing turkish characters


Scott,

Thanks for your explanation it was very helpful.
I have made the changes for V5R1 (including changing the prototype for the additional parameter for open)

It compiles and runs without any errors.

But..... nothing is written to the file, when the file opens in EDTF it is empty, when I look in it using WRKLNK it is empty.

Is there something I left out?

The program execution does not generate any errors.
The file is created with code page 1208

John

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Thursday, May 31, 2012 4:57 PM
To: RPG programming on the IBM i / System i
Subject: Re: Attempting to write to IFS andmissing turkish characters

Hi John,

There are always two text encodings involved.. The encoding of the
data in your program (normally some flavor of EBCDIC, but not always) and the encoding of the data in the stream file (assuming you want to open the file with Notepad, it should be some flavor of either ASCII or
Unicode.)

You mention 7F and 7C in code page 1026... which is a nice start. But, you don't mention whether that's the file's code page or the program's code page. Though, I'm guessing it's the program's code page, based on the context.

CH5ASCII, as written, uses the default CCSID of the job to derive the program's code page. It never attempts to specify the program's code page, so if you've changed the code to specify 1026 instead of 819, you've told it to translate from your job's EBCDIC data (within which, 7C/7F probably aren't the characters you expect) to Turkish EBCDIC in the file (which is almost definitely not what you wanted -- and certainly won't be readable in Notepad.)

Please also note that CH5ASCII was written for V4R5, and there have been two enhancements to the IFS APIs since then that are useful to your
scenario:

1) With V5R1, the IFS supports CCSIDs, which are more powerful than (and just as easy to use as) code pages. Simply use the O_CCSID flag instead of the O_CODEPAGE one.

2) With V5R2, the open() API supports creating a file and performing translation in a single call, with the O_TEXT_CREAT flag. This simplifies your code. It also makes it possible to do auto-translation on file systems that don't support setting a CCSID in the file header (such as /QNTC).

While you might be able to make your program work without these two enhancements, I heartily recommend using them. They just make life easier, and your program more robust.

So please code something like this:

fd = open( '/whatever'
: O_CREAT + O_CCSID + O_TEXTDATA
+ O_TEXT_CREAT + O_WRONLY + O_INHERITMODE
: 0
: 1208
: 1026 );

data = x'7C7F';
callp write(fd: %addr(data): 2);
callp close(fd);

That assumes that you want the stream file to be CCSID 1208 (UTF-8). If that's not correct, please choose the proper flavor of ASCII for Turkish characters -- and make sure that you're running on a version of Windows that supports the Turkish ASCII. (Unicode is so much simpler!)

You might also consider using Unicode on the RPG side as well... :-)


On 5/31/2012 11:19 AM, John Allen wrote:
I am attempting to write/create a txt file directly into the IFS the
file contains Turkish characters



I have a copy of Scotts great and very helpful IFS eBook (Thank you
very much Scott)



This file contains turkish characters such as ÜŞ

It appears using code 1026 these characters are Hex 7F and Hex 7C



For my test I did the following:

1) Modified Scotts program CH5ASCII that creates and writes some simple text to a text file

2) Changed the code that creates a new file to specify code page 1026 rather than 819

3) Output some text including a Hex 7F7C



Runs fine, but when the file is opened from the 400 (EDTF) I see a “@
I was expecting to see ÜŞ

When I open it with Notepad I see jibberish
Ä…™@Ö¤¢‰•k%%É@“–¥…@£ˆ…@¦



Obviously there is something I am missing



Anybody know what I am doing wrong?



Thanks



John










_____

I am using the Free version of SPAMfighter<http://www.spamfighter.com/len> .
SPAMfighter has removed 3429 of my spam emails to date.

Do you have a slow PC?<http://www.spamfighter.com/SLOW-PCfighter?cid=sigen> Try free scan!

--
This is the RPG programming on the IBM i / System i (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.


--
I am using the free version of SPAMfighter.
We are a community of 7 million users fighting spam.
SPAMfighter has removed 3493 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

The Professional version does not have this message

--
This is the RPG programming on the IBM i / System i (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 ...

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.