lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I'm trying to have an open file dialog load a text file into a multiline, but although the text does get loaded it doesn't show up in my editor::

function item_open:action()
   open_dlg:popup (iup.CENTER, iup.CENTER)
   if open_dlg.status == "0" and open_dlg.fileexist == "YES" then
       local file =, "r")
       local text = file:read("*a")
       edit_box.value = text
   return iup.DEFAULT

Antonio Scuri wrote:

If you want to keep your script running while interacting with a dialog, then you must call iup.MainLoop. You can do it inside the script you open,
or you can do it after calling dofile.


-----Original Message-----
From: [] On Behalf Of Merick
Sent: domingo, 16 de setembro de 2007 12:27
Subject: lua + iup help

I'm using FreeBasic to make a lua script interpreter, and dynamically linking to iup with iuplua51.dll and iuplua51controls.dll. The way I have it now, when you start the interpreter it automatically loads a script called "main.lua"

The default main.lua that I will be packaging with the interpreter uses iup.filedlg to let the user select a lua script, which will the be run with dofile. This by itself works fine, however if I try to run any of the demo lua scripts from the iup package, although they do run and display the demo dialogs, the scripts immediately exit back to the main.lua script which pops up the open file dialog again. At this point, although the dialog created by the demo script is still on screen, it can't be interacted with at all. I tried adding a couple different types of loops to pause the script, but although adding them to the demo scripts kept them from returning back to main, I'm still unable to interact with the dialog created by the demo.

Can anyone tell me how to run a loop and still be able to use the created dialog?

Here's the script I'm using for main.lua:

main_loop = true

main_open_dlg = iup.filedlg{dialogtype = "OPEN", title = "Run Lua Script", filter = "*.lua", filterinfo = "Lua Scripts", directory=exepath().."\\scripts", nochangedir = "NO"} while main_loop do
    main_open_dlg:popup (iup.CENTER, iup.CENTER)

    if main_open_dlg.status == "0" then
        if main_open_dlg.fileexist == "YES" then
            iup.Message("File does not exist!", main_open_dlg.value)
    elseif main_open_dlg.status == "-1" then
local main_quit = iup.Alarm("FB Lua", "No script selected, exit interpreter?" ,"Yes" ,"No")
        if main_quit == 1 then             main_loop = false
View this message in context:
Sent from the Lua - General mailing list archive at