**Solved** Dialog not displaying

I have the following code in main() just after show()


If targetAddress = "" then
    
        showOKDialog("Notice","Due to Roku restrictions, blah blah blah blah........")
           
    Else
    
        ' debug testing... why is this not displaying either
        showOKDialog("Test",targetAddress)
    
    End if

and then…


Sub showOKDialog(title = "NOTE" as String,message = "Press OK to continue" as String)

    port = CreateObject("roMessagePort")
    dialog = CreateObject("roMessageDialog")
    dialog.SetMessagePort(port)
    dialog.SetTitle(ttl)
    dialog.SetText(message)
 
    dialog.AddButton(1, "OK")
    dialog.EnableBackButton(true)
    dialog.Show()
    
    While True
        dlgMsg = wait(0, dialog.GetMessagePort())
        If type(dlgMsg) = "roMessageDialogEvent"
            if dlgMsg.isButtonPressed()
                if dlgMsg.GetIndex() = 1
                    exit while
                end if
            else if dlgMsg.isScreenClosed()
                exit while
            end if
        end if
    end while

End Sub

… but the dialog is never displayed. What gives?

What code do you have in main()?


Sub Main()

    'initialize theme attributes like titles, logos and overhang color
    initTheme()

    'display a fake screen while the real one initializes. this screen
    'has to live for the duration of the whole app to prevent flashing
    'back to the roku home screen.
    screenFacade = CreateObject("roParagraphScreen")
    screenFacade.addParagraph("Please wait...")
    screenFacade.show()

    ' =========================
    ' GET SETTINGS FROM REGISTRY
    ' =========================
    targetAddress = RegRead("ip")
    targetPort = RegRead("port")
    targetUsername = RegRead("username")
    targetPassword = RegRead("password")
    
    If targetAddress = "" then
    
        showOKDialog("Notice","Due to Roku restrictions, only blah blah blah....") ' to fix later
           
    Else
    
        ' debug testing... why is this not displaying either
        showOKDialog("Test",targetAddress)
    
    End if

That is literally the only thing leading up to the sub for the dialog. The program displays fine (“Please wait…”) but nothing else ever happens.

The RegRead and RegWrite are some simple ones that I found on the forum here that a lot of folks seem to be using.

Nevermind, fixed!

I had to change it to a function, for whatever reason. I did make a few other minor modifications so I can’t say for sure that’s what did it, but here’s the code:


Function showOKDialog(title = "NOTE" as String,message = "Press OK to continue" as String,buttonText = "OK" as String) as Void

    port = CreateObject("roMessagePort")
    dialog = CreateObject("roMessageDialog")
    dialog.SetMessagePort(port)
    dialog.SetTitle(title)
    dialog.SetText(message)
 
    dialog.AddButton(1, buttonText)
    dialog.EnableBackButton(true)
    dialog.Show()
    
    While True
        dlgMsg = wait(0, dialog.GetMessagePort())
        If type(dlgMsg) = "roMessageDialogEvent"
            If dlgMsg.isButtonPressed()
                If dlgMsg.GetIndex() = 1
                    exit while
                End If
            Else If dlgMsg.isScreenClosed()
                exit while
            End If
        End If
    End While

End Function