TIP: Click on subject to list as thread! ANSI
echo: foxpro
to: MICHAEL DOUGHERTY
from: WIM DE LANGE
date: 1997-03-17 07:42:00
subject: Scoping Issues

Hello Michael!
14 Mar 97 23:52, Michael Dougherty wrote to Den Barnes:
 MD> The screen control (@ GET) calls a procedure, which conditionally
 MD> calls another procedure to do the specific work in each case.
 MD> When the working procedure tries to reference the global
 MD> variable, the procedure works the first time it is entered- but
 MD> the second time the procedure is called, the program halts
 MD> because the variable (my public constant) cannot be found.  Debug
 MD> shows no value just after control passes to the procedure (the
 MD> second time)
Do you give the public variable as a parameter to a procedure? In that case, 
the original variable becomes hidden to the calling procedure and all 
procedures that are called within. Very bad, for a public declared variable. 
What you can do to find the problem, is to put the variable in you debug 
window, and put a stop on this variable (a bullet in the middle column). When 
the variable is not available any more, the program is also stopped. A 
solution is, to put () arond any public variable used in a procedure call, so 
the variable is passes by value, instead of by reference.
 MD> Is there a scoping restriction that makes variables available
 MD> only to immediate child procedures, but not grandchildren?  Is
No, there isn't.
 MD> parameters?  (possibly something like VBa (Excel 5.0)
 MD> "ParamArray")
Such a solution is not available.
Groetjes,
   Wim
Fido: 2:281/554.11     CompuServe: 100142,604
Internet: wdelange@biochem.nl wdelange@pi.net
--- GoldED 2.42.G1121
---------------
* Origin: WiMar Soft (2:281/554.11)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.