ark1320 Posted January 30 Report Posted January 30 What is a good way to keep a Lua script from terminating? One way I found is to put a "dummy" (empty) do while true at the end of the script like this: WIndow Script code here do while true end In the particular case I have, the script above simply opens a window for display that I want another script to be able to use. So I don't want the window to close. I pass the window's handle to the other script, and this seems to work OK. The other script is called frequently as data is entered, and if I put the window definition code in that script, then each time the script runs the window flashes. If the window stays open there is no flashing. I just wonder if there is a better way to keep the window script from terminating then using the empty do while true? Thanks, Al
John Dowson Posted January 30 Report Posted January 30 You can do that but I would not recommend it - a script should run and exit when finished. There is no other way to keep a lua thread running as this should not be necessary. Create the window in the other script and try to eliminate whatever is causing the "flashing".
ark1320 Posted January 30 Author Report Posted January 30 A flash happens when a window is opened, and since the "other" script is called numerous times, the window is opened and flashes each time. I don't think there is a good solution for this kind of situation. Thanks, Al
John Dowson Posted January 31 Report Posted January 31 If you want the window to be always open, then you should have one script that creates the window and then waits for events to update the windows contents. The events could be anything - an offset change, a flag change, a button or key press/release, an event, etc. You do not need two scripts, or to create the window each time.
ark1320 Posted January 31 Author Report Posted January 31 10 hours ago, John Dowson said: If you want the window to be always open, then you should have one script that creates the window and then waits for events to update the windows contents. The events could be anything - an offset change, a flag change, a button or key press/release, an event, etc. You do not need two scripts, or to create the window each time. I understand John, and in fact have a number of scripts that do just that. This was a particular situation where as an experiment I did not want to use an event driven script. Thanks, Al
John Dowson Posted February 1 Report Posted February 1 13 hours ago, ark1320 said: This was a particular situation where as an experiment I did not want to use an event driven script. You could also register for an event but do nothing in the event handling function- just registering for the event will keep your script running/window open. You could even use a timer event if you wanted to close the window after a number of seconds/minutes. The lua script that updates the window could run the lua that creates the window if the window isn't available/created yet, or use the handle if the window was available. If using an endless loop to keep the window open, maybe add a sleep call in the loop body. John
ark1320 Posted February 1 Author Report Posted February 1 6 hours ago, John Dowson said: You could also register for an event but do nothing in the event handling function- just registering for the event will keep your script running/window open. You could even use a timer event if you wanted to close the window after a number of seconds/minutes. The lua script that updates the window could run the lua that creates the window if the window isn't available/created yet, or use the handle if the window was available. If using an endless loop to keep the window open, maybe add a sleep call in the loop body. John John -- interesting ideas, thanks very much! Al
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now