Sign in to follow this  
Followers 0
faldo

"while" blocks everything :/

6 posts in this topic

Greetings,

I was wondering if there is a simple way to create a while... wend. statement without having to block the "time flow" of the entire code.

I use while primarily to avoid geting recursive errors but as it is now, i have to create a separate process for every while statement that runs in the background so that it won't block the GUI etc. of the main process.

Thanx in advance, i don't think i've ever met more helpfull guys than in this board,

cheers

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm not sure if I fully understand that, but here are my first thoughts.

If you're using a GUI, could you set the option for GUIOnEventMode and use that? With OnEvent mode, your while loop is separate from the rest, and you use GUISetOnEvent and GUICtrlSetOnEvent to designate functions to be called when the event occurs.

Or, could you just have one large while loop with everything inside, and maybe functions and stuff to get out? It's a long shot, but it's all I've got right now.

Maybe some code/more detail would help.

Edited by greenmachine

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Maybe i can try and explain better what i mean:

- Create a GUI

- insert a few checkboxed into the GUI

- create a while statement somewhere in the code that has nothing to do with the GUI itself.

- have GUIGetMsg() look for changes in the checkboxes

Now, my problem is that i unless the "while" statement is true, it will block the entire timeframe to the script so that GUIGetMsg() never checks anthying... nohting else will do anything for that mater... until the while statement becomes true.

All this is so easy to do with simple If... else... EndIf. but since i need to have recursive function calls in my loops the "if" wont work and "while" will since it doesn't care about recursivness.

Edited by faldo

Share this post


Link to post
Share on other sites

1. Can't you put GUIGetMsg() into the while loop?

2. You should check out GUIOnEventMode. It's in the helpfile. Let me know if you need any help with it, but I think that would benefit you.

3. Some actual code would really help.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thanx for the GUIOnEventMode hint... however, the GUI was just an example of what gets blocked... the while statement blocks every single line in the code outside the while section until its true.

I guess all i need to know is if there is SOME way to let a while loop work on its own without having to block the timeframe of the script. In other words, instead of having to create a separate process that runs a constant while loop, be able to put it in the script somewhere whithout it interupting the script itself.

If noone understands me, i'll put some code in here, it's just that the script is over 5000 lines long and it would take time to extract the exact info.

Edited by faldo

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I guess all i need to know is if there is SOME way to let a while loop work on its own without having to block the timeframe of the script. In other words, instead of having to create a separate process that runs a constant while loop, be able to put it in the script somewhere whithout it interupting the script itself.

Short answer is no. A script can't be executing two completely separate loops at the same time, since that would require the location of the current code line to be two places at once. If one of the loops only needs to check for something occasionally, you could use Adlib.

Posting the entire code of your script may not be necessary, but it would be helpful if you told us exactly what you'd like it to be doing.

Edited by Sokko

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0