Typically the GUI and your application are separated because of the reactive nature of the GUI library. Most of your code for reacting to GUI events will go into a GUIObjects event handler.
-- # ...
myButton.eventHandler = function(app, instance, event)
if event == "touch" then
-- # react to touch event. Alter state, etc...
I don't have the time to test this my self but you could try using OpenOS threads to give control back to your main script.
-- # ... more stuff up here
local thread = require 'thread'
-- # Gui logic n stuff...
-- # This will now run whenever the main script yields i.e event.pulls, os.sleeps, etc..
local guiProc = thread.create(application.start, application)
-- # Continue below with main program runtime logic.
-- # Be aware that the GUI will only be able to process stuff when this main script yields as Lua is single threaded
Multiline text is handled by GUI.textBox rather than GUI.text as far as I can tell.
Hope this helps you over the initial hump. Happy to help more if you still need it