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



Hi Alan,

two points worth paying attention to:

* the length of PathFile2read - is it sufficient to accommodate PriorPathfile and x'00' character?
* it might be more convenient to use options(*string *trim) in name/mode parameters definition, in this case you don't have to add x'00' to the end of the field:
dcl-pr OpenFile pointer extproc('_C_IFS_fopen') ;
*n value ; //File name
*n value ; //File mode
end-pr ;
...
OpenMode='r';
PathFile2read='yourfile.txt';
FilePtr = OpenFile(PathFile2read:OpenMode);

I think this should work

Regards,
Alexei

-------- Original Message --------
Subject : Using _C_IFS_fopen and _C_IFS_fgets to read files in the ifs
From : Alan Shore via MIDRANGE-L midrange-l@xxxxxxxxxxxxxxxxxx
To : "midrange-l@xxxxxxxxxxxxxxxxxx" <midrange-l@xxxxxxxxxxxxxxxxxx>
Cc : Alan Shore <ashore@xxxxxxxx>
Date : Sunday, July 25, 2021 21:39

Hi everyone
I just re-read my e-mail and realized that it is misleading
Using that web site -
A better way to read a file in the IFS with RPG @ RPGPGM.COM<https://www.rpgpgm.com/2016/03/a-better-way-to-read-file-in-ifs-with.html>
The problem is with the the OpenFile

Here is the pertinent code

dcl-pr OpenFile pointer extproc('_C_IFS_fopen') ;
*n pointer value ; //File name
*n pointer value ; //File mode
end-pr ;

dcl-pr ReadFile pointer extproc('_C_IFS_fgets') ;
*n pointer value ; //Retrieved data
*n int(10) value ; //Data size
*n pointer value ; //Misc pointer
end-pr ;

dcl-pr CloseFile extproc('_C_IFS_fclose') ;
*n pointer value ; //Misc pointer
end-pr ;


PathFile2read = %trim(PriorPathfile) + x'00' ;
OpenMode = 'r' + x'00' ;
FilePtr = OpenFile(%addr(PathFile2read):%addr(OpenMode)) ;

if (FilePtr = *null) ;
CannotreadPriorBAI2();
return;
endif ;



Alan Shore
Solutions Architect
IT Supply Chain Execution

[cid:image001.png@01D78162.E7C4C710]

60 Orville Drive
Bohemia, NY 11716
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
E-mail : ASHORE@xxxxxxxxxxxxxxxxxxxx

'If you're going through hell, keep going.'
Winston Churchill

From: Alan Shore
Sent: Sunday, July 25, 2021 1:26 PM
To: midrange-l@xxxxxxxxxxxxxxxxxx
Subject: Using _C_IFS_fopen and _C_IFS_fgets to read files in the ifs

Hi everyone
We are on V7r3
We have a number of files in the ifs that I am attempting to use _C_IFS_fopen, _C_IFS_fgets and _C_IFS_fclose to read
Please see the following web page
A better way to read a file in the IFS with RPG @ RPGPGM.COM<https://www.rpgpgm.com/2016/03/a-better-way-to-read-file-in-ifs-with.html>

I have a situation where one of the files is not read by these utilities
Does anyone know how I can determine why?
I am able to go into that file using wrklnk and edtf - so I believe its NOT an authority situation

However, the program is not able to read the rest of the files AFTER that one
I can sign off, sign back in, change the program to start AFTER that one particular file, and the rest of the files can be read
So I am assuming that something needs to be initialized after such a read, but In am unable to find anything as to what that could possibly be
Does anyone have any knowledge of such a situation and how to rectify it?

As always - all answers gratefully accepted

Alan Shore
Solutions Architect
IT Supply Chain Execution

[cid:image003.png@01D78162.E7C4C710]

60 Orville Drive
Bohemia, NY 11716
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
E-mail : ASHORE@xxxxxxxxxxxxxxxxxxxx<mailto:ASHORE@xxxxxxxxxxxxxxxxxxxx>

'If you're going through hell, keep going.'
Winston Churchill


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.