Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
vrihlea
Level 7

Difference between sub and function ?

' main.brs
    screen = CreateObject("roSGScreen")
    m.port = CreateObject("roMessagePort")
    screen.setMessagePort(m.port)

    m.scene = screen.CreateScene("MasterNode")
    m.scene.id = "MasterNode"

    screen.show()


' MasterNode.brs

' in init()
m.global.observeField("fire","eventFired")


' if eventFired is a -function- everything is ok
' if I rename it to -sub- the the device just freezes
function eventFired()
    LogDEBUG(m.pageName, "EVENT SENT TO m.global.fire: ")
    if isValid(m.global.fire) and isValid(m.global.fire.event)
        firedEvent = m.global.fire.event
        handleEvent(firedEvent)
    end if
end function


Any idea on why this happens ?
0 Kudos
2 Replies
belltown
Level 7

Re: Difference between sub and function ?

Are you remembering to change end function to end sub?
https://github.com/belltown/
0 Kudos
vrihlea
Level 7

Re: Difference between sub and function ?

my bad, the issue was with a `return invalid` in a child function that I renamed before that. thanks
0 Kudos