If you want to return an Object sometimes and an Integer others, you have to make the return type of the function "Dynamic":
function FindCurrDateObject(date as Integer) as Dynamic
This can lead to other problems because you can't just test to see if it returns 0. For example:
if FindCurrDateObject(date) = 0 then
' do whatever
end if
This will throw an error if FindCurrDateObject returns an object. Likewise if it does return 0 then you'll get the error you're seeing when you try to access the returned value as an object (i.e., ?CurrDateObject.text)
To be honest, returning "invalid" is probably the better way to go since you can always test for a return of invalid.
There's probably other ways to accomplish whatever it is that you're trying to do like returning empty strings for title and text instead of 0 or invalid.
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.