Just a small question

Is there in Xojo a function or command which gives the opportunity that the code breaks out of a routine, do something else, like mouseclick, and continues with the routine after the event (say mouseclick again).

I am from the vb6 generation :wink: and in there was a command available which did this:

If doevents() then
end if

When you put this inside a loop, the loop will temporarely be broken, when ie. you click the mousebutton, do the event and returns to the loop and continues where it did leave the loop. This way we could also avoid that a screen locked while running a loop.

I run through several loops in the application I wrote in Xojo and everything is running fine, but you see that the windows are locked during the loops, this is physically shown that the window goes down on the screen by 1/10th mm and returns to its original position when the loop is ended.

This does not have any disturbance for the routine, but it gives a restless view on the screen.

At the moment the screen freezes temporarily the code runs through a 36 times loop which downloads a file (so, 36 files) from the internet, analyzes and formats it and write the results to disk in a uniform way, while the data from the internet is not received in a uniform way.

of course

exit while
exit if
exit function or
exit sub

etc.

You should probably use threads for something like that.

hmmm, does exit not leave the loop forever and does not come back where it left the loop?

What I am talking about is:

for I is 1 to 1000 (run 1000 times this loop)

vb6 command: if doevents() then
end if

when I click a button in loop number 345 the button action will be performed and when this is finished it returns to the loop where it left the loop …so continue with loop 345

next

ok, Marcus, that was what I was afraid of :slight_smile:

Does this also release my screen during the loop, so it will not move anymore when entering and leaving the loop?

You can call the

App.DoEvents()

However, I’ve read numerous times on this forum that using App.DoEvents is not very good practice… so use at own risk.

ah now I understand… except in Console Apps DoEvents is evil… evil… evil…

hmmm…ok, thanks for the responses… I will go on now to see what is best practice :slight_smile:

You mention events in you post. XOJO is event driven. If you have an mouse-click event handler, then you need do nothing special, click the mouse, an event is dispatched to the queue, and processed.

What exactly are you thinking you need to handle specifically? Remember the paradigm for VB6 and for XOJO are quite different, VB6 played at event driven. for XOJO its being serious about it.

DO NOT USE DO EVENTS like you might have in VB
It’s NOT the same
Xojo is architecturally different than VB so its effects are different
IF you find you need a loop that leaves the UI responsive this is a good spot for a thread

I am looking into threads now, thank you all.