Hello, sorry for maybe stupid question, but I'm stuck while creating menu.
I'm trying (about 14 days of trying and searching) to start and stop "while" cycle by buttons, but when I start cycle then menu stops responding.
I tried all sorts of crazy constructions, but I just couldn't. Certainly it will be related to the fact that I play it in the same thread ...I just don't know how the threads work in LUA, so if anyone would want to advise me, I'll be glad.
Please is there any way I can start and stop a "while" cycle using the form with button ?Here is my last example of start/stop menu - that stops responding after start of course...
local val = false
function Main()
frmMain = Obj.Create("TForm")
frmMain.Left = 0
frmMain.Top = 0
frmMain.Width = 100
frmMain.Height = 100
frmMain.Font.Name = "Arial"
frmMain.Font.Size = 8
frmMain.Caption = "Some testing text"
frmMain.OnClose = function(pSender) Obj.Exit() end
frmMain.FormStyle = 3
btnStartStop = Obj.Create("TButton")
btnStartStop.Caption = "Start/stop"
btnStartStop.OnClick = function(pSender) btnOnClick(not val, pSender) end
btnStartStop.Parent = frmMain
btnStartStop.Top = 10
btnStartStop.Left = 20
btnStartStop.Width = 100
frmMain.Show()
Obj.Loop()
end
function btnOnClick(value)
while value == true do
print("...")
wait(500)
end
end
function Clean()
Obj.Free(btnStartStop)
Obj.Free(frmMain)
end
Main()
Clean()
Thank you very much for your suggestions.