rudi Posted March 7, 2023 Share Posted March 7, 2023 Hello, in this thread https://www.autoitscript.com/forum/topic/209820-unterminated-string-maybe-longer-than-5000-chars/ I noticed for the first time the function qualifier "Volatile", and don't really get the help file explanation: The following rules apply to functions that are declared with this qualifier: Callback function During function execution the main AutoIt's message pump is not blocked as it normally is for non-Volatile callbacks. COM event function The execution is synchronous (see example). What is the "autoit message pump"? what is the callback function? Searching the help file I just find Call() ? What are scenarios, where it's making sense to use the function qualifier "volatile"? CU, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
mistersquirrle Posted March 7, 2023 Share Posted March 7, 2023 (edited) I was also interested in it a bit when replying in that thread, I hadn't really ever seen Volatile before, meaning that I also haven't seen anyone else use it. I played around with the example a little bit, and it does change behavior in the example with it and without it. For instance, check out the page on the COM function that the example is putting Volatile in front of: https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768280(v=vs.85) On the microsoft page it says: "Synchronous No", and Volatile says: "COM event function The execution is synchronous". If you run the example with and without Volatile, you get different results. With Volatile, it prevents the page from loading when you try to navigate to it (because BeforeNavigate2 sets Cancel to True). Without Volatile it doesn't prevent the page from loading, likely because the navigation request goes through before the $bIECancel actually takes effect. So Volatile making it synchronous allows the $bIECancel flag to actually cancel the request before it goes through. I didn't understand and couldn't find a difference in behavior with a callback function, I'm also unsure of what the "AutoIt Message Pump" is. I just tried some basic tests with AdlibRegister and HotKeySet during a callback function and there was no noticeable difference. For CallBack, I just used the example from: https://www.autoitscript.com/autoit3/docs/functions/DllCallbackRegister.htm Edited March 7, 2023 by mistersquirrle We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
water Posted March 7, 2023 Share Posted March 7, 2023 (edited) I use this keyword in some of my Excel, Word and Outlook example scripts.Example: An event in Outlook is raised before a mail gets sent. The user defined event function is called and if "volatile" is used Outlook waits for a reply of the function. If you set the return value to True, the send operation is canceled. If "Volatile" is not used Outlook calls the user defined event function but does not wait for a reply and immediately continues processing by sending the mail. Edited March 7, 2023 by water Typo fixed My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
rudi Posted March 7, 2023 Author Share Posted March 7, 2023 Thanks to both of you for the replies! Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Werty Posted March 7, 2023 Share Posted March 7, 2023 I remember this old thread about non-blocking functions using volatile, a small example inside... https://www.autoitscript.com/forum/topic/158598-dllcallbackregister-with-non-freezing-gui-volatile-example/?tab=comments#comment-1150646 ..also an incomplete attempt at MoveFileWithProgress by jaberwacky. rudi 1 Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
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