Difference between Self.LB and LB

a. In a MenuHandler, I pass LB to another window LB Property (to be able to make search operations).

b. In a different one (I probably wrote it at a different time), I pass Self.LB from the same window to the same window (as the one above).

In case a: everything works OK, nothing to say.

In case b: I get another instance, empty) of the core window (the window where LB and Self.LB is set).

Thus my question:
what is the difference between LB and Self.LB ?

Just for the record, I use the following code:

wSearch.LB = LB


wSearch.LB = Self.LB

wSearch does not have any Listbox, only a Property named LB.

Self just forces a scope, just as wSearch does … and in this case probably isn’t necessary (unless you have multiple items named LB and you want to make the code explicit)

If you do not specify a scope designator (Self, Wsearch etc), Xojo assumes it is the current scope, then searchs Private (ie. same class or Module), then Public or Global designators

Sounds like implicit instantiation is turned on

Jeff, Dave: Thank you.

I think so too. I will check right now… yes, it is.

It is by default.

It is necessary in this case. I do not recall why I removed the leading Self., but my application (in this special case) worked fine (until the next discovery… *).

So, these are different (Self.Control_Name and Control_Name), and can lead to … errors.

  • Each time I think i have a good (not strong, good !) build, I fall into all kinds of traps… I never was a game player :frowning:

As I probably mistakenly understand it, Self.control_name refers to an instance of the control, kinda like “one of me”. Whereas control_name refers to the control itself. In my mind, I generally equate control_name with me.control_name.

That’s an idea.

Except they really aren’t. There are a very few cases where there would be a difference and your code would still compile. Normally, if they are different, you’ll get a compile error, because only one is actually in scope. (Eg., within a class definition, SELF.anything can’t refer to an instance of a control on a window.)

There must be something else going on to cause your initial results, and you’ve changed enough stuff that it has gone away for some unknown reason.

I presume, then, that the actual problem was that you were using wSearch in such a way that it caused a new instance of the window to be created. That has nothing to do with Self.LB vs. LB. It does not indicate that there is any difference between them. In the context of your code (assuming that the MenuHandler is on the window, not the app or another control, in which case you would get a compile error) there is no difference. They are exactly the same.