Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: turned a sentence into a NOTE as it has relevance and needs to be pointed out as such

...

Code Block
port = CreateObject("roMessagePort")
screen1 = CreateObject("roParagraphScreen")
screen1.SetMessagePort(port)
screen1.AddParagraph("first screen")
screen1.Show()

while true
    message = wait(0, port)
    if message.isScreenClosed() then
		exit while
	end if
end while

screen2 = CreateObject("roParagraphScreen")
screen2.SetMessagePort(port)
screen2.AddParagraph("second screen")
screen2.Show()
screen1.Close() ' close after new screen has been shown

while true
    message = wait(0, port)
    if message.isScreenClosed() then
		exit while
	end if
end while

...

Note
This code displays the new screen before the old screen is closed.  This is important both to avoid screen flicker and to avoid premature termination of your app.  Recall that when the last screen on the stack is closed, the app exits.  If you close the only screen on the stack and then try to create a new one, your app will exit before it gets a chance to create the new screen.

Facade screen

Another way to avoid having an empty screen stack is to create a facade screen which always remains on the stack until your app is ready to exit.  An app that uses this technique might begin like this:

...