简体   繁体   中英

(Lua/IUP) Check if one function is done before executing the next function

I have 2 functions. A function that displays a dialog that allows the user to choose which string to extract, and a function that can extract strings according to what the user chose in the dialog.

I want them to run one after another inside the open file function. Before this, having the extract function only makes it all work. But with the addition of the first function, now I have to ask the function to wait for the dialog in another before it can execute its function.

What happened is that it just goes through all the functions without actually waiting on their results. This resulted in the values being nil because the function was not even finished yet. So now I'm trying to find a way for the program to wait on the results, before continuing the program, either in IUP or in Lua.

How do you check to make sure that one function is finished before the other function can continue, especially if the first function happens to be a IUP dialog?

Here's the link to the sample code, with the first and second functions in use, and they are called within a function which is responsible for opening files.

https://controlc.com/906426ce

Thanks in advance

I don't know IUP. But if the dialog is not blocking until you are done you could simply put everything that is supposed to happen after the dialog in a separate function and call it from the dialogs close button/event. So call that in function btn_ch1:action() for example.

Welp. I'm dumb. Someone suggested to just get the functions from the main function used for opening files, before placing them into their separate functions. This resulted in the program just needing to call only one function, and everything just happens according to order.

Thanks to that other guy who tried to solve my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM