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



Tim,

The reply of -1 means the open failed. To learn more, you can retrieve the 'errno' (a global variable in the ILE C environment, but you can get a pointer to it from RPG to find out what it is... more info at link below)
http://www.scottklement.com/rpg/ifs_ebook/errors.html

Also I see you are manually adding x'00' and passing %ADDR() to open. There's a feature of RPG that will simplify this called options(*string) -- add this to your prototype and RPG will automatically add the x'00' and pass the address, so you can code it like this:

fd = open('/tmp/file.txt' : etc etc );

-or-

fd = open(%trimr(filename): etc etc );

(in the 2nd example, I did not need to manually add x'00' to "filename")

As you can see, that makes the code a lot simpler and cleaner. There's also an options(*trim) if you don't want to code %trim() on the call to open() as well.

I would also consider using constants for the flags, permissions, etc. I couldn't tell you off the top of my head what 8388682 means... but, if you use constants for the value, then the code is much easier to understand.

Good luck!


On 12/10/2015 9:21 AM, tim wrote:
i have the following code that is returning a -1 result.

filename = '/tmp/file.txt' + x'00';
fd = openf(%addr(filename) : 8388682 : 420 : 819 ) ;

i dont know why -1 is being thrown. i dont see anything in joblog. where
can i find out what is causing the problem?


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.