Referring to values in code

Hi Carl:

I am attempting to modify the history graph goodie. Can you see why the following first line of code works, but not the next?

As a background, I have a container cntDatasets on the root container, on which is a label lblTank. On cntDatasets I have several datasets, one of which is a string called strTank. I can reference the text value of the label, but I cannot seem to assign a value to the dataset strTank to a value.

Tank = event.source.parent.getComponent(“cntDatasets”).getComponent(“lblTank”).text
print Tank -----THIS ONE IS OK
root.getComponent(“cntDatasets”).setPropertyValue(“strTank”, Tank)
strTank = event.source.parent.getComponent(“cntDatasets”).strTank
print strTank -----THIS ONE DOES NOT WORK.

TIA D. Lewis

Hey David, hope you don’t mind me jumping in here…

Looks like the problem is probably the fact that you can’t refer to custom properties by just saying “.name” such as where you have:

Instead, you must use “getPropertyValue”. So try changing that line to:

strTank = event.source.parent.getComponent("cntDatasets").getPropertyValue("strTank")

Also, “root” isn’t a valid way of getting to the root container, but I figured you probably have that defined above or something.

Hope that helps,

Colby: Hey, whoever can take the time to wade through my code, thanks!

That line worked, thanks. I am sure I’ll be back with more.