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



You need to put the procedures in the same module.  The files will be global
to everything in that module.

> -----Original Message-----
> From: Doc [SMTP:Doc6502@yahoo.com]
> Sent: Thursday, February 13, 2003 6:48 PM
> To:   rpg400-l@midrange.com
> Subject:      How do I share an open file handle across procedures?
> 
> Hey All
> 
> I've got a small problem in ILE that I'm trying to understand.  The 
> question is this:  can I open a file in a subprocedure, but have a 
> different subprocedure write to the file?
> 
> So, I have something like this
> 
> -----------------------------------------------
> 
> ModuleA
> h nomain
> fQDDSSRC   if   e             disk    rename(QDDSSRC:DDSREC)
> f                                     usropn
> 
> dfunca            pr 
> 
> pfunca            b                   export 
> 
> dfunca            pi
> 
>   /Free 
> 
>    open QDDSSRC; 
> 
>   /End-Free
> 
> pfunca            e
> 
> -----------------------------------------------
> 
> ModuleB
> 
> h nomain
> 
> fQDDSSRC   if   e             disk    rename(QDDSSRC:DDSREC)
> f                                     usropn
> 
> dfuncb            pr
>  
>                                pfuncb            b 
> export 
> 
> dfuncb            pi
> 
>   /Free
>    if not %open(QDDSSRC); // dummy open 
> 
>      open QDDSSRC;
>    endif;
> 
>    read DDSREC;
> 
>   /End-Free
> 
> pfuncb            e 
> 
> -----------------------------------------------
> 
> I build Modules A and B, and bind them into a service program.  No
> problem.
> 
> -----------------------------------------------
> 
> Then I have one more Module, Module C, which looks like this:
> 
> dfunca            pr
> dfuncb            pr
> 
>   /Free
>     funca();
>     funcb();
>     *inlr = *on;
>   /End-Free
> 
> I compile Module C, and create a program with Module C and the service 
> program.  It runs, but no data from QDDSSRC shows up on the read. 
> Looking at the Open File display, I see that there are two ODP's 
> issued-- one for the OPEN in FuncA, and one for the open in FuncB.
> 
> So I thought if I just did an OVRDBF FILE(QDDSSRC) 
> TOFILE(<mylibrary>/QDDSSRC) SHARE(*YES) OVRSCOPE(*JOB) I might have it. 
>   It still ran, but I get the same result-- no data read.  The share 
> numbers increment in the Open File display when the OPEN command runs in 
> FuncA and FuncB, so I know the share is at least active.
> 
> I'm missing something fundamental here and I can't figure out what it is.
> 
> Any ideas?
> 
> Thanks!
> 
> -Doc
> 
> 
> 
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.


************************************************************************************************************************************************************************************************************
This message originates from Lincare Holdings Inc. It contains information 
which may be confidential or privileged and is intended only for the individual 
or entity named above.
It is prohibited for anyone else to disclose, copy, distribute or use the 
contents of this message. 
All personal messages express views solely of the sender, which are not to be 
attributed to Lincare Holdings Inc., and may not be copied or distributed 
without this disclaimer. 
If you received this message in error, please notify us immediately at 
MailAdmin@lincare.com or (800) 284-2006.
************************************************************************************************************************************************************************************************************


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.