On Jan 17, 2007, at 2:19 PM, johnf wrote:

> So when I create an instance of dTextBox why would I lose
> the dabo namespace?

        The question itself shows the problem. You aren't "losing" anything.  
You are operating in a different namespace, and that new namespace  
doesn't know what 'dabo' is until you tell it.

        Since we're using VFP analogies, think of local variables: when you  
call another method, that new method doesn't know anything about any  
locals declared in the calling procedure. You didn't "lose" those  
variables; the new procedure has its own local variable 'namespace'.  
So if the calling procedure has:

LOCAL lcName
lcName = "John"
myfunc()
? "TOP LEVEL", lcName

FUNCTION myfunc
        * This will throw an error
        ? lcName
        LOCAL lcName
        lcName = "Ed"
        ? "MYFUNC", lcName
        RETURN

        Notice how 'lcName', even though defined in the calling procedure,  
is not available in the function until you create it. Then, when  
control returns to the main program, the original 'lcName' is still  
intact; changing a variable in the function that happened to have the  
same name didn't affect it, since those variable names were in  
different namespaces. You could think of them as actually being named  
'toplevel.lcName' and 'myfunc.lcName', clearly showing that they are  
not the same thing.

        Hope this helps,

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to