New developer here... This should be easy for someone with experience
I'm creating a new field in an interface tag and trying to set the value before I run the object. I print the field inside the object and it is always empty. It is as if the field is READONLY from outside the object. Here is some test code from the final ScreenGraph tutorial
Near the top of TutorialPanelSetScene.xml I have inserted this line of code:
sub init() print "Init ()" m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"
m.readContentTask = createObject("roSGNode", "ContentReader") m.readContentTask.observeField("content", "setcategories") m.readContentTask.contenturi = "http://www.sdktestinglab.com/Tutorial/content/categoriescontent.xml" m.readContentTask.test = "TEST" m.readContentTask.control = "RUN" end sub
In ContentReader.xml I have added this code:
<interface> <field id = "contenturi" type = "uri" /> <field id = "test" type = "string" /> <field id = "content" type = "node" /> </interface>
and this code:
sub getcontent() print "in ContentReader getcontent()" print "m.top.contenturi is " m.top.contenturi print "m.top.test is " m.top.test ...
What firmware# is that? Sometimes due to race conditions assignments between threads may fail, though i doubt this is your case. Follow the adage "divide and conquer", e.g. put a print right after assignment and so on, till you narrow where the issue happens
m.readContentTask.test = "TEST" ? "checking on m.readContentTask.test", m.readContentTask.test
Wait a minute. Scratch everything older than this post. I did what you said and got the same results, but when i scrolled up I noticed there were two sets of printouts from the Task. The first set had the fields filled in. Evidently the example creates another instance somewhere else and calls the task where I have not set the "test" value. That's what I get for trying to recreate an issue in the example code. I thought everyone would be more familiar with the example code.
So I returned the code that I am writing, put in similar print statements, and found that my Task object is getting fired when I do the CreateObject before I fill in the fields. So the question is what would make the Task fire before I set the Control field to "RUN"?
Here is the code in the calling procedure: Sub Init() Print "***************************************" Print "CountrysideMainScene.Init ()"
Issue Resolved. I misinterpreted the purpose of the Init function in the task. It is supposed to run when the object is created. The FunctionName that it sets is what gets triggered when the Control field is set to RUN. I made the mistake of trying to call the main part of the task in the Init function.
"piyushg098" wrote: was this issue resolved? I am also facing this issue.
which of the two issues mentioned above are you referring? Maybe start a new topic and link to this one. The first guy figured out his problem, the second guy jacked the thread with a totally off topic post.