Re: /IUP/ Help needed with examples
- Posted by dr_can Jan 08, 2016
- 2079 views
_tom said...
dr_can said...
I am trying a version of the Alert example:
-- Example 2 -- Alarm include gui/iup/iup.e constant reply = {"File saved sucessfully - leaving program", "File not saved - leaving program anyway", "Operation cancelled"} procedure main( sequence cmd = command_line() ) IupOpen( 0, {} ) integer b = IupAlarm("IupAlarm Example", "File not saved! Save it now?" ,"Yes" ,"No" ,"Cancel") -- Shows a message for each selected button printf(1, "The response is: %s", {reply[b]}) if getc(0) then end if IupMessage("Save File", reply[b]) IupClose() end procedure main()
Lines 14 & 15 are added to prove that b is correctly returned; why doesn't the IupMessage get invoked?
Try this:
include iup/iup.e constant reply = { "File saved sucessfully - leaving program", -- 1 "File not saved - leaving program anyway", -- 2 "Operation cancelled" -- 3 } IupOpen(NULL) integer b = IupAlarm( "IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel" ) ? b -- 1 | 2 | 3 IupMessage( "Hello Message", reply[b] ) IupClose()
I can't explain, but I always remove lines of code until a program works.
_tom
Whatever variation in IupOpen parameters, console interrogation, use or non-use of "main", Greg's addition of an empty dialog is always required. However, if you add the line:
IupShow( IupDialog( NULL ) ) -- show an empty dialog
before Line 1511 in iup.e
then the Lua example on the Iup site could be replicated via:
include gui/iup/iup.e constant hello = "Hello Message" IupOpen(NULL) switch IupAlarm( "IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel" ) do case 1 then IupMessage(hello, "File saved sucessfully - leaving program") case 2 then IupMessage(hello, "File not saved - leaving program anyway") case 3 then IupMessage(hello, "Operation cancelled") end switch IupClose()