DECLARE GLOBAL / EXTERN

Nancy Palmquist nlp at vss3.com
Mon Jul 30 12:33:22 PDT 2007


Kenneth Brody wrote:
> Note that it is perfectly acceptable to have DECLARE EXTERN in the
> main processing, and DECLARE GLOBAL in the CALLed table, as long as
> you don't use the variable until you call the table that actually
> defines it with the DECLARE GLOBAL.  I do this all the time.

I can say this logic works well.  In a programming setup where I was 
using a large set of library processes that would be called from 
multiple filepro files, I found I could manage it best if I put all the 
declare globals in a called library table.

Then each file that does a call does the call to declare the global 
variables first, then does the library calls required.

Then I only had the variable definitions in one process table and could 
change edits or lengths without updating 20+ tables.

I usually did this step in @once to insure that it was done before 
anything else and it was always done.

I also found that I like to keep the DECLARE's in the table that needs 
them.  So the call table would have the list of DECLARE EXTERN's that it 
needed at the top and not a cut&paste list that included a lot of other 
stuff.


Nancy

> 
> Example:
> 
> ===== Main processing:
> 
> ::end:
> @entsel::show "\{T} - test declare extern/global combo":
> ::end:
> ::declare extern MyVariable:
> @keyT::' MyVariable = "from input":
> ::call "called":
> ::mesgbox "Back in input.  MyVariable is '" & MyVariable & "'":
> ::end:
> 
> ===== Called processing:
> 
> ::declare global MyVariable(30,*):
> ::mesgbox "In called processing":
> ::MyVariable = "set in called":
> ::end:
> 
> =====
> 
> This will run just fine.  However, if you uncomment the assignment in
> the main prc, you will get the error when the CALL is executed, and
> the variable will not take on the (30,*) setting.
> 
> In more complex library scenarios, I often have an "init" table with
> all of the DECLARE GLOBALs needed by the library, in addition to any
> required initializations, which gets called prior to using any of
> the library routines themselves.
> 


-- 
Nancy Palmquist 		MOS & filePro Training Available
Virtual Software Systems	Web Based Training and Consulting	
PHONE: (412) 835-9417		   Web site:  http://www.vss3.com


More information about the Filepro-list mailing list