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



Thank you Mr. Klement. I guess I did not quite understand how all that worked 
together and I think I was doing it incorrectly.

I appreciate your taking the time to help me.

Dave Johnson

Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote: 
> Does anyone have or can point me to, an example of reading an IFS file 
> in RPG, that is not a text file?  That is, lets say that I have a zip 
> file stored in my ifs and i want to read it and write it out to another 
> system via a socket, for example.  I can find all kinds of examples of 
> how to read text files (O_Text), but no one seems to want to explain, 
> with an example that actually works that is, how to read a non-text 
> file.  I even checked Mr. Klement's website/tutorial and his example, to 
> the best of my knowledge, is for simple text files only.

Actually, I don't discuss text files until Chapter 5 of my online 
tutorial.  Everything prior to that is binary stream files. In fact, in 
chapter 2 I create a Windows .COM executable program in the IFS:
http://www.scottklement.com/rpg/ifs_ebook/ch2rawdta.html

It'd be hard to find anything further from a text file than that! :)

The answer to your question is: Don't use O_TEXTDATA in the open flags.
Once you've done that, anytime you read the file you'll get the raw bytes 
in the file with no translation.  Whatever you write to the file will be 
written as-is with no translation.

If your goal is to send a ZIP file out to a socket (I'll assume TCP) you 
do this (pseudocode):

a) Create socket
b) Connect socket
c) Say whatever you need to say to get the other side ready for your file
d) open() the file (don't use O_TEXTDATA)
e) read() a chunk of data from the file
f) send() the chunk of data to the socket
g) repeat steps E & F until you get an error on the read() or send() APIs.
h) close() the file
i) If you're still connected (no fatal error sending data) say anything 
that needs to be said to tell the other side that you're done.
j) close() the socket

I wrote an article for iSeries NEWS entitled "RPG and the IFS: Binary 
Stream Files" that attempts to talk about non-text files, though really 
there's not much to say, but it does demonstrate creating a .BMP image 
file in the IFS from scratch using RPG. (You'll need a ProVIP membership 
in the iSeriesNetwork [which is included with the magazine subscription] 
to read the following link)
http://www.iseriesnetwork.com/article.cfm?id=19751

---
Scott Klement  http://www.scottklement.com


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.