m.CurrDateObject = FindCurrDateObject(m.itemContent.date)
?"title :"m.CurrDateObject.title //Here I got Type Mismatch Error When 0 comes
?"text :"m.CurrDateobject.text
‘FindCurrDateObject Return Object when if condition true in function
‘when if condition false then it’s return 0
‘Here, I received two different data types on the function
- If Condition true => Object
- If Condition false => 0 as Integer
Can anyone suggest How can I manage this two data types on Roku?
function FindCurrDateObject(date as Integer) as Object
m.date = CreateObject("roDateTime")
m.myObject = {}
for each item in m.global.itemArray
now = m.date.AsSeconds()
if (now >= date) then
m.myObject.title = item.title
m.myObject.text = item.text
return m.myObject
//This below-mentioned part works, but it's called every time. I don't want to return the invalid value
'else
'return invalid
end if
end for
end function
2
Answers
The function FindCurrDateObject can be improved like this-