Forum Discussion

vrihlea's avatar
vrihlea
Visitor
9 years ago

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 ?

2 Replies

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