Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vrihlea
Visitor

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 2
belltown
Roku Guru

Re: Difference between sub and function ?

Are you remembering to change end function to end sub?
0 Kudos
vrihlea
Visitor

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