On 7/30/2022 3:53 PM, Paul Dupuis via use-livecode wrote:
My understanding of 'wait 0 with messages' is that it will cause any pending messages, that are not scheduled for a time later than the current time, in the pendingMessages queue to be processed before continuing. Messages later than the current time (when the statement is executed) will not be processed (yet).

Is this correct?


First, than you to those that have responded.

The reason I got curious about 'wait 0 with messages' (or even just 'wait 0') is because of an epiphany I had just last week regarding a bug a customer reported in our software. The customer experienced and execution error and our software presents a custom dialog that allows them to email out support account some information, including the 'executionContexts' so we have some code debugging information.

The problem as a 'can't find object' error. In reviewing the code, I could see no way that the error should have occurred. The code was using the ChartMaker library to create a graph. It all looked good per documentation and we could not reproduce the error in house. I then noticed a 'wait 0 with messages' prior to the line the error occurred on and noticed that the line that had the error used object references relative to the current stack (which the defaultStack was explicitly set to much prior).

My epiphany was realizing - for the first time, despite LiveCodeing since HyperCard and having a Masters in Computer Science and my entire career being in the IT/software development space for over 40 years - that when the 'wait 0 with messages' is executed, if there was a pending USER click on another window, the defaultStack could change and then the relative object references would not be able to find their target objects.

Perhaps I should have realized that a 'wait 0 with messages' COULD result in the defaultStack changing much sooner OR perhaps I should always fully qualify all object references (which I have been doing for quite a few years, but this was old code), but it is a 'gotcha' of using wait with messages I had never thought of.

The Dictionary Entry (LC 9.6.8) does state "If the wait..with messages form is used, LiveCode continues normal processing during the wait. The current handler is frozen, but the user can start other handlers and perform other actions such as switching cards." and 'switching cards' does imply changing the context of relative object references even if the defaultStack does not change, so perhaps I should have realized, but didn't until just last week.

Now I am very curious about exactly what wait 0 with messages does and also about what actions change the defaultStack. Does anyone know of an article or something someone has done to identify all the messages, commands, or functions that change (or potentially change) the defaultStack?




_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to