1. Imperfect Understanding
- Posted by jessedavis Apr 20, 2023
- 519 views
I thought Euphoria was a procedural language. When one calls a procedure the procedure must complete and return prior to continuing program execution.
Apparently this is not true. To wit:
if fn < 1 then MsgBox = message_box("Unable to open taa.cfg file", "Fatal Error", #10) closeApp() end if
In practice MsgBox executes it moves to closeApp() but before closeApp() finishes execution moves to following code. resulting in the application never closing.
These are win32lib routines:
global procedure closeApp() if mainWindow != 0 then closeWindow(mainWindow) end if end procedure
Any help with my limited understanding would be appreciated.
2. Re: Imperfect Understanding
- Posted by ghaberek (admin) Apr 20, 2023
- 520 views
Your understanding is mostly correct. Routines calling each other build a "stack" which is basically a running list of routine calls. So in this case you're looking at a stack like this:
Level 1: <TopLevel> Level 2: message_box() Level 1: <TopLevel> Level 2: closeApp() Level 3: closeWindow()
But that's not the problem here. I think your code is running as designed but you're not aware of what closeApp() is designed to do.
The closeApp() routine is very simple: it checks if the application has a main window and if so, it tells that window to close. It's just shorthand for you calling closeWindow(MyWindow) directly.
When the Win32Lib docs talk about the "app" it doesn't mean the entire program of Euphoria code; it's specifically referring to everything running inside the event loop handled by WinMain().
So if you're calling closeApp() before you've started the "app" by calling WinMain(), then closeApp() will do nothing for you. In that case you're better off using abortErr() to force the entire program to stop.
-Greg
P.S. I updated your post to correct the formatting. Using <eucode> tags helps format code. And you don't need to use double-backslash \\ for line breaks; a simple empty line will suffice. You can click Edit on your post to see my changes.
3. Re: Imperfect Understanding
- Posted by jessedavis Apr 20, 2023
- 502 views
Thank you.
I better understand this. I will work on my formatting.