way the break dont work?
27 is "Esc"
for i = 1, 1000000 do
Label.SetText("Label1", i);
if e_Key == 27 then
break;
end
end
Professional Software Development Tools
way the break dont work?
27 is "Esc"
for i = 1, 1000000 do
Label.SetText("Label1", i);
if e_Key == 27 then
break;
end
end
There's nothing inside that loop to check for the key. It just checks what the value of e_Key is.
Assuming you have that in an On Key event, that loop is going to happen every time you press a key, because the whole loop is inside the event -- the loop doesn't start until the key is pressed. It will count up to 1000000 for every key except the Esc key, which will just count up to 1.
If you wanted to check a key press from within a loop like that, you'd need to use a DLL or something to check the current key state.
Another way to do this would be to use a timer to do the counting, and make your script in the On Key event set a variable that affects the counting in the On Timer event, or just stops the timer, etc.
--[[ Indigo Rose Software Developer ]]
Code:for n=1, 10000 do if System.IsKeyDown(27) then break end Application.Sleep(1) end
Last edited by Worm; 09-28-2006 at 10:00 AM.
...or use System.IsKeyDown. Heh.
I thought we had something like that, but I couldn't remember the name and didn't find it in the help file. Doh.
Thanks Worm.![]()
--[[ Indigo Rose Software Developer ]]
I got your back Lorne
I'd used User32.dll's GetKeyState in the past until someone pointed System.IsKeyDown out to me. Wish I could give credit where its due, but who that was escapes me.
In the limited testing I've done, it's important to have the Application.Sleep or the key never is processed.