Re: wait 0 with messages (and the defaultStack)

2022-08-01 Thread Paul Dupuis via use-livecode
Yea, a number of years ago, I went to always fully qualifying object 
references through all the techniques you mentioned, but we've just not 
had a chance to scrub the entire code base (100,000 lines+) and so this 
one got missed until now.


We're now going through the entire code base to catch any last cases 
where object references could be in error due to any wait with messages 
statements (combined with user actions).



On 8/1/2022 4:16 PM, Bob Sneidar via use-livecode wrote:

As my application(s) became more complex, I also ran into topstack and curentcard issues. 
As a result, I am in the habit now of either using "of me" appended to every 
command of in a card or stack script, or else sending the long id of an object to a 
command or function that is not in the message path.

For instance, if I am processing all the fields on a card, I put the handler in the card script 
and then use the form 'field "myField" of me' to reference each field. Even better, 
if I reference the object repeatedly I will 'put the long id of  of me' 
into a variable initially, then use the variable as a reference.

Bob S



On Aug 1, 2022, at 12:43 , Paul Dupuis via use-livecode 
 wrote:

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.


___
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



___
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


Re: wait 0 with messages (and the defaultStack)

2022-08-01 Thread Bob Sneidar via use-livecode
As my application(s) became more complex, I also ran into topstack and 
curentcard issues. As a result, I am in the habit now of either using "of me" 
appended to every command of in a card or stack script, or else sending the 
long id of an object to a command or function that is not in the message path. 

For instance, if I am processing all the fields on a card, I put the handler in 
the card script and then use the form 'field "myField" of me' to reference each 
field. Even better, if I reference the object repeatedly I will 'put the long 
id of  of me' into a variable initially, then use the 
variable as a reference. 

Bob S


> On Aug 1, 2022, at 12:43 , Paul Dupuis via use-livecode 
>  wrote:
> 
> 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.


___
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


Re: wait 0 with messages (and the defaultStack)

2022-08-01 Thread Bob Sneidar via use-livecode
It's my understanding that wait allows idle messages from the engine to be 
sent. When that happens, any send in time messages are processed. Wait with 
messages allows any other messages including engine messages to be processed. 

For instance, I have a FindBar object that uses wait 1 second with messages in 
a keyDown handler so that as the user continues to type the keystrokes can be 
processed. If the user pauses for 1 or more seconds, the code that performs the 
find is triggered, and then I exit to top to prevent any more unnecessary 
processing (otherwise the loop would keep going until all the keystrokes were 
processed). 

Bob S


> On Aug 1, 2022, at 12:43 , Paul Dupuis via use-livecode 
>  wrote:
> 
> 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


Re: wait 0 with messages (and the defaultStack)

2022-08-01 Thread Paul Dupuis via use-livecode

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