Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Bill_O on August 11, 2020, 10:57:50 AM

Title: message box with yes or no
Post by: Bill_O on August 11, 2020, 10:57:50 AM
I found some old threads about different message boxes.
I could use one with a yes or no option.
When I did any option for the message box it gave me an error.
Why is this code not working?

Code: [Select]
--------------------------------------
--test
---------------------------------------
function Test()
inst = mc.mcGetInstance()
rc = wx.wxMessageBox("Testing yes no box",2)
if (rc == 2) then
wx.wxMessageBox("Yes was pressed")
elseif (rc == 8) then
wx.wxMessageBox("No was pressed")
else
wx.wxMessageBox("Did not work")
end
end
---------------------------------------------------------------


Thanks,
Bill
Title: Re: message box with yes or no
Post by: SwiftyJ on August 11, 2020, 11:50:56 AM
Hi Bill,

Try

Code: [Select]
rc = wx.wxMessageBox("Message", "Title of box", wx.wxYES_NO)
if (rc == wx.wxYES) then
--yes was pressed
elseif  (rc == wx.wxNO) then
--no was pressed
end
Title: Re: message box with yes or no
Post by: Bill_O on August 11, 2020, 12:20:13 PM
Swifty,

Worked great.
I had tried some code similar to what you showed but was missing a few little things.
Thanks for the help.

Bill