×
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.
I have used Scott Klement's guides for IFS file access and they have been
incredibly helpful, but I am now working on an FTP interface and I have a
problem I can't seem to overcome.
I have prototyped open and close and I am using Scott's readline almost
verbatim as an external procedure to my program. I have an interface
process that determines the type of message I have received by reading the
header inside each file. There is a group of 3 programs that read the list
of files, and then opens each file to see if it should process them.
The problem I am facing is that when I open, readline and close an IFS
file in the first program, subsequent programs called by the same parent
process open the same file and get line 2 of the file instead of line 1
like that first program. They therefore never process the transaction. Any
help would be appreciated, thanks for your time.
If it helps, here is my copy of readline:
//ReadLine - Get a line at a time from an IFS file
P $_readline B export
D $_readline PI 10I 0
D fd 10I 0 value
D text * value
D maxlen 10I 0 value
D rdbuf S 1024A static
D rdpos S 10I 0 static
D rdlen S 10I 0 static
D p_retstr S *
D RetStr S 32766A based(p_retstr)
D len S 10I 0
c eval len = 0
c eval p_retstr = text
c eval %subst(RetStr:1:MaxLen) = *blanks
c dow 1=1
C* Load the buffer
c if rdpos>=rdlen
c eval rdpos = 0
c eval
rdlen=read(fd:%addr(rdbuf):%size(rdbuf))
c
c if rdlen < 1
c return -1
c endif
c endif
C* Is this the end of the line?
c eval rdpos = rdpos + 1
c if %subst(rdbuf:rdpos:1) = x'25'
c return len
c endif
C* Otherwise, add it to the text string.
c if %subst(rdbuf:rdpos:1) <> x'0d'
c and len <> maxlen
c eval len = len + 1
c eval %subst(retstr:len:1) =
%subst(rdbuf:rdpos:1)
c endif
c enddo
c return len
P $_readline E
Here is my implementation of Open:
//=========================================================================================
// $_Open - Opens a file by filename in the IFS.
//
// Takes a whole bunch of parameters that define how the file is
opened
// Returns a file handle.
// Uses API open - for more info see "IFS" Api Reference, V5R3
//=========================================================================================
P $_open B
D $_open pi 10I 0
D prpPath * Value Options(*String)
D prO_Flag 10I 0 Value Options(*NoPass)
D prMode 10U 0 Value Options(*NoPass)
D prCodepage 10U 0 Value Options(*NoPass)
D open pr 10I 0
ExtProc('open') IFS file open BIF
D * Value Options(*String)
D 10I 0 Value
D 10U 0 Value Options(*NoPass)
D 10U 0 Value Options(*NoPass)
D fd s 10I 0
D filename s 200A
D Flags s 10I 0
D Mode s 10U 0
D Codepage s 10U 0
/FREE
if %parms = 1;
//Default file open parameters
Flags = O_RDWR + O_APPEND + O_CREAT + O_TEXTDATA;
Mode = S_IRWXU + S_IRGRP + S_IROTH;
CodePage = 819;
else;
//Try setting all of the parameters
Monitor;
Flags = prO_Flag;
On-Error;
Flags = O_RDWR + O_APPEND + O_CREAT + O_TEXTDATA;
endmon;
Monitor;
Mode = prMode;
On-Error;
Mode = S_IRWXU + S_IRGRP + S_IROTH;
endmon;
Monitor;
CodePage = prCodePage;
On-Error;
CodePage = 819;
endmon;
endif;
fd = open(prpPath:Flags:Mode:CodePage);
return fd;
/END-FREE
P $_open E
CONFIDENTIALITY NOTICE: The ICS information and all ICS attachments
contained in this electronic communication are legally privileged and
confidential information and intended only for the use of the intended
recipients. If the reader of this message is not an intended recipient,
you are hereby notified that any review, use, dissemination, distribution
or copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately of the
error by return e-mail and please permanently remove any copies of this
message from your system and do not retain any copies, whether in
electronic or physical form or otherwise. Thank you.
ICS, Inc. (904) 399-8500
As an Amazon Associate we earn from qualifying purchases.
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.