Forum Discussion
kernfamily4
9 years agoVisitor
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 ()"
m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"
'** Create Countryside API object
Print "*****Before Create"
m.GetData = createObject ("roSGNode", "APICountryside")
Print "*****After Create"
'** Get Filter Data
Print "======================================="
m.GetData.RequestType = "FilterData"
m.GetData.MediaItem = "TEST"
Print "m.GetData -----------------------------"
? m.GetData
m.GetData.Control = "RUN"
If m.GetData.ReturnCode <> 1
Print "Error retrieving Filter Data " m.GetData.ReturnCode
'Return
End If
Here is the code in the Task procedure:
<component name = "APICountryside" extends = "Task" >
<interface>
<field id = "RequestType" type = "string" />
<field id = "MediaItem" type = "string" />
<field id = "ReturnCode" type = "integer" />
</interface>
And
Sub Init()
Print "***************************************"
Print "APICountryside.Init ()"
Print "Request Type: " m.top.RequestType
Print "Media Item " m.top.MediaItem
Print "m.top ---------------------------------"
? m.top
If m.top.RequestType = "FilterData"
m.top.functionName = "GetFilterData"
Else
Print "Invalid Request Type: " m.top.RequestType
m.top.ReturnCode = -1
End If
End Sub
Here are the Results:
(Notice the "After Create" is below the data from the Task)
***************************************
CountrysideMainScene.Init ()
*****Before Create
***************************************
APICountryside.Init ()
Request Type:
Media Item
m.top ---------------------------------
<Component: roSGNode> =
{
functionName:
control: init
state: init
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id:
MediaItem:
RequestType:
ReturnCode: 0
}
Invalid Request Type:
*****After Create
=======================================
m.GetData -----------------------------
<Component: roSGNode> =
{
functionName:
control: init
state: init
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id:
MediaItem: TEST
RequestType: FilterData
ReturnCode: -1
}
Error retrieving Filter Data -1
If you have any ideas they would be greatly appreciated. In the mean time I am going to cut down my code to do nothing but call an empty task and build it up from there.
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 ()"
m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"
'** Create Countryside API object
Print "*****Before Create"
m.GetData = createObject ("roSGNode", "APICountryside")
Print "*****After Create"
'** Get Filter Data
Print "======================================="
m.GetData.RequestType = "FilterData"
m.GetData.MediaItem = "TEST"
Print "m.GetData -----------------------------"
? m.GetData
m.GetData.Control = "RUN"
If m.GetData.ReturnCode <> 1
Print "Error retrieving Filter Data " m.GetData.ReturnCode
'Return
End If
Here is the code in the Task procedure:
<component name = "APICountryside" extends = "Task" >
<interface>
<field id = "RequestType" type = "string" />
<field id = "MediaItem" type = "string" />
<field id = "ReturnCode" type = "integer" />
</interface>
And
Sub Init()
Print "***************************************"
Print "APICountryside.Init ()"
Print "Request Type: " m.top.RequestType
Print "Media Item " m.top.MediaItem
Print "m.top ---------------------------------"
? m.top
If m.top.RequestType = "FilterData"
m.top.functionName = "GetFilterData"
Else
Print "Invalid Request Type: " m.top.RequestType
m.top.ReturnCode = -1
End If
End Sub
Here are the Results:
(Notice the "After Create" is below the data from the Task)
***************************************
CountrysideMainScene.Init ()
*****Before Create
***************************************
APICountryside.Init ()
Request Type:
Media Item
m.top ---------------------------------
<Component: roSGNode> =
{
functionName:
control: init
state: init
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id:
MediaItem:
RequestType:
ReturnCode: 0
}
Invalid Request Type:
*****After Create
=======================================
m.GetData -----------------------------
<Component: roSGNode> =
{
functionName:
control: init
state: init
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id:
MediaItem: TEST
RequestType: FilterData
ReturnCode: -1
}
Error retrieving Filter Data -1
If you have any ideas they would be greatly appreciated. In the mean time I am going to cut down my code to do nothing but call an empty task and build it up from there.