TOPIC: Uninitilized members
#1378
Uninitilized members 1 Year, 2 Months ago
I have problem with 2 objects that have in class. When the app is running, I can see the objects there. But they are to member variable, but these produce warnings (member not initialized). I do not understand other objects in class are connected to some member vars with no problem. Is there situation where object is created but will the connection to the member var fail?
 
 
#1382
Re:Uninitilized members 1 Year, 2 Months ago
What are the names of the members that are a problem?

You know that member names must start with a capital letter to be public?

Sometimes it is helpful to insert Inspect(object) or Inspect(this) calls into your code so you can examine data. Or even insert a deliberate error (e.g. a reference to an uninitialized variable) to get into the debugger so you can look around.
 
 
andrew
 
#1383
Re:Uninitilized members 1 Year, 2 Months ago
Thanks for the informations. I was not clear i think.
What I have is class with 2 chooselist object and 2 flipcontrols. They are all connected during construction phase like this:
.obj_cl1 = .Vert.chooselist1

Now I have a hook for the chooselists: NewValue(source,value). There it checks chooselist source like this:
if (source is .obj_cl1) ... etc.

This works only for 1 chooselist, never with both, i can only get both chooselist in the hook using if (source.Name is...). I do not know why.

One other thing: if I use flipcontrol SetCurrent() I get the 'uninitialized member' error when the method is used from the NewValue hook method. When I use it at other places it works fine.

Maybe I have to change names to start with the capitals to get it fix, but do not understand why that is only needed in some case. I thought they would be class members that i can refer to in all my class code?
 
 
#1386
Re:Uninitilized members 1 Year, 2 Months ago
You are right, the members should not need to be public if you are accessing them within the same class.

Here is a simple example that seems to work.

Code:

Controller
    {
    New()
        {
        .first = .Vert.first
        .second = .Vert.second
        }
    Controls: (Vert
        (ChooseList (one two) name: first)
        (ChooseList (three four) name: second)
        )
    NewValue(value, source)
        {
        if source is .first
            Alert('first')
        if source is .second
            Alert('second')
        }
    }



Maybe you can cut down your code to help find the problem.
 
 
andrew
 
#1387
Re:Uninitilized members 1 Year, 2 Months ago
I have experiment a bit more and maybe see some issue.

What I have is: flipcontrol#1, contains choosecontrol#1. Choosecontrol#1 controls flipcontrol#2, which contain choosecontrol#2.

I start from begin again with building the screen components. If I have 2 choosecontrols in a vertcontrol, all works fine. I put 1 choosecontrol in a flipcontrol, and the 'uninizialized member' warning comes. Then I remove all choosecontrols and only have flipcontrol and the error still there. The structure I use is like: obs = Object("FlipControl", etc. I do get the error message, but also a screen with all components. I try another options like the style you used in the example, but get no screen at all, just errors. Maybe some syntax problems. Here is my try:
Code:


Controller
{
Controls: (Vert
(ListView name: list)
(Flip
(ChooseList #('one', 'two' ) name:'a' )
(ChooseList #('hoi', 'bye' ) name:'b' )
name: flip)
)
New()
{
.list = .Vert.list
.flip = .Vert.Flip
.a = .Vert.Flip.a
.b = .Vert.Flip.b
}
NewValue(value, source)
{
if (source is .list) Print('list' )
if (source is .flip) Print('flip' )
if (source is .a) Print('a' )
if (source is .b) Print('b' )
}
}


I am wonder why the flipcontrol seems to cause problems with initialization. When I do Inspect I can see the component is there, so why the error? Is the component maybe destroyed after the screen was shown?
File Attachment:
File Name: suneido.txt
File Size: 496
 
 
Last Edit: 2009/06/09 13:08 By Peter.
 
#1388
Re:Uninitilized members 1 Year, 2 Months ago
You had "name: flip" but were trying to reference it as ".Vert.Flip"

But after fixing that and adding a Flip button so I could test, it seems to work fine for me.

Code:

Controller
    {
    Controls: (Vert
        (ListView name: list)
        (Button Flip)
        (Flip
            (ChooseList #('one', 'two' ) name:'a' )
            (ChooseList #('hoi', 'bye' ) name:'b' )
            name: flip)
        )
    New()
        {
        .list = .Vert.list
        .flip = .Vert.flip
        .a = .Vert.flip.a
        .b = .Vert.flip.b
        }
    On_Flip()
        {
        .flip.Flip()
        }
    NewValue(value, source)
        {
        if (source is .list) Print('list' )
        if (source is .flip) Print('flip' )
        if (source is .a) Print('a' )
        if (source is .b) Print('b' )
        }
    }

 
 
andrew
 
#1389
Re:Uninitilized members 1 Year, 2 Months ago
aaah, the small typo's :-D

Thanks!!