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



On Fri, 7 Jan 2005 07:10:28 -0800, Tony Carolla <carolla@xxxxxxxxx> wrote:
> I am writing a set of modules to parse through several report text
> files, and extract usable information, for assimilation into our
> patient database.  Basically, there are 11 report formats, with a
> distinct header at the beginning of each report, and the data can be
> parsed out from these, based on which format of report you are
> reading.
> 
> So I had the idea to make one subprocedure for each report format, and
> then a main procedure that reads through the file, and based on what
> format the report line came from, hands it to the appropriate
> subprocedure.
> 
> The next hurdle is the fact that, not every report contains the
> account number and the data in the same line.  You might get the
> account number, then on the next line, the denial message.  What I
> need to do is have some of the subprocedures 'remember' the previous
> account number they have read, in case the next one doesn't have one.
> 
> As far as I know, each time a subprocedure is called, it's variables
> are all initialized, so this means that, for each subprocedure, I need
> a global set of variables in the main procedure that it can store
> stuff in.  This just doesn't seem to go with what I believe
> subprocedures were designed for.  If I want to use one of these
> subprocedure in another program, I have to duplicate the global
> variables from the main program.
> 
> Is there a way to make some variables in a subprocedure persistent?

all procedures, whether you call them subprocedure or not are in a
module.  And a module can have as many global variables as you want. 
those globals persist until the activation group ends.   Just declare
the global variables outside of a procedure.

Tony, the "proper", that is modular way of doing what you want is to
declare a data struct in your main procedure.  I would call it
"ControlBlock" or something like that.  It would contain all the state
information pertaining to the set of transactions you are processing. 
Info about the previous line would be stored in this control block
structure.   Then pass that struct by reference to each of the sub
procedures.  The sub procedures now have a common, modular place to
put and get information that pertains to all the other sub procedures.

-Steve

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.