m.CurrDateObject = FindCurrDateObject(m.itemContent.date)
?"title :"m.CurrDateObject.title //Here I got Type Mismatch Error When 0 comes
?"text :"m.CurrDateobject.text
'FindCurrDateObject 当函数中条件为 true 时返回对象 '当条件为假时返回0 '在这里,我在函数上收到了两种不同的数据类型
有人可以建议我如何在 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
函数FindCurrDateObject可以这样改进-
function FindCurrDateObject(date as Integer) as Object
date = CreateObject("roDateTime")
myObject = {}
now = m.date.AsSeconds()
for each item in m.global.itemArray
if (now >= date)
myObject.title = item.title
myObject.text = item.text
exit for
end if
end for
return myObject
end function