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


Re: wait 0 with messages

2022-08-01 Thread Bob Sneidar via use-livecode
This is correct. 

Bob S


> On Jul 31, 2022, at 12:14 , J. Landman Gay via use-livecode 
>  wrote:
> 
> On 7/31/22 12:04 AM, Mark Wieder via use-livecode wrote:
>> I don't think "wait 0" by itself does anything useful. Make a stack with two 
>> buttons. Running the script in the first button will prevent mouseUp events 
>> in button 2 from being processed.
> 
> I think it must do something, "wait 0" is a workaround for bug 22453 (and 
> 18924 which is now marked as a duplicate.) I had to use the workaround and it 
> works.
> 
> So my take is that any wait allows LC to do housekeeping, and "with messages" 
> also allows app-generated messages. I'd like to get a confirmation from the 
> team though.
> 
> -- 
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.com
> 
> ___
> 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

2022-07-31 Thread Mark Wieder via use-livecode

On 7/31/22 12:14, J. Landman Gay via use-livecode wrote:

On 7/31/22 12:04 AM, Mark Wieder via use-livecode wrote:


I don't think "wait 0" by itself does anything useful. Make a stack 
with two buttons. Running the script in the first button will prevent 
mouseUp events in button 2 from being processed.


I think it must do something, "wait 0" is a workaround for bug 22453 
(and 18924 which is now marked as a duplicate.) I had to use the 
workaround and it works.


So my take is that any wait allows LC to do housekeeping, and "with 
messages" also allows app-generated messages. I'd like to get a 
confirmation from the team though.


That's pretty bizarre. I wonder what's going on. All I can think of is 
that processing the wait command gives the java JNI command enough time 
to recover before processing the mobileControlSet vscroll command. And 
ios wouldn't need that extra time because there's no java interaction.


--
 Mark Wieder
 ahsoftw...@gmail.com

___
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

2022-07-31 Thread J. Landman Gay via use-livecode

On 7/31/22 12:04 AM, Mark Wieder via use-livecode wrote:


I don't think "wait 0" by itself does anything useful. Make a stack with two buttons. Running 
the script in the first button will prevent mouseUp events in button 2 from being processed.


I think it must do something, "wait 0" is a workaround for bug 22453 (and 18924 which is now 
marked as a duplicate.) I had to use the workaround and it works.


So my take is that any wait allows LC to do housekeeping, and "with messages" also allows 
app-generated messages. I'd like to get a confirmation from the team though.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
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

2022-07-30 Thread Mark Wieder via use-livecode

On 7/30/22 19:02, Paul Dupuis via use-livecode wrote:


So Mark,

Your understanding is that 'wait 0' (WITHOUT with messages) would allow 
OS events like a screen redraw, USB drive insertion/removal, etc. but 
NOT livecode engine events in the queue like mouseDown, mouseUp, 
resumeStack, etc,


OR

That wait 0 (again without with messages) would include in addition to 
OS events, LC built-in events like mouseDown, resumeStack, etc., but not 
custom messages (or LC standard messages) sent to the queue via sent in 
time?


I don't think "wait 0" by itself does anything useful. Make a stack with 
two buttons. Running the script in the first button will prevent mouseUp 
events in button 2 from being processed.


button 1 script:
on mouseUp
  repeat forever
wait 0
  end repeat
end mouseUp

button 2 script:
on mouseUp
  put the name of me & cr after msg
end mouseUp

Now hit command-period to exit to the debugger, change the script of 
button 1 to


on mouseUp
  repeat forever
wait 0 with messages
  end repeat
end mouseUp

and you can click button 2 and see new text in the message box.

--
 Mark Wieder
 ahsoftw...@gmail.com

___
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

2022-07-30 Thread Paul Dupuis via use-livecode

On 7/30/2022 7:49 PM, Mark Wieder via use-livecode wrote:

On 7/30/22 12:53, 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?


My understanding of this is close but not quite the same.
The "wait 0 with messages" statement is the fastest implementation 
("wait 0") of an opportunity for the system event loop to process any 
pending instructions. The "with messages" statement in effect yields 
control to the event loop to check if any "send in time" messages have 
timed out and are pending or to handle other tasks that may have 
accumulated (mouse or keyboard events, etc).




So Mark,

Your understanding is that 'wait 0' (WITHOUT with messages) would allow 
OS events like a screen redraw, USB drive insertion/removal, etc. but 
NOT livecode engine events in the queue like mouseDown, mouseUp, 
resumeStack, etc,


OR

That wait 0 (again without with messages) would include in addition to 
OS events, LC built-in events like mouseDown, resumeStack, etc., but not 
custom messages (or LC standard messages) sent to the queue via sent in 
time?


Thanks for responding!


___
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

2022-07-30 Thread Mark Wieder via use-livecode

On 7/30/22 12:53, 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?


My understanding of this is close but not quite the same.
The "wait 0 with messages" statement is the fastest implementation 
("wait 0") of an opportunity for the system event loop to process any 
pending instructions. The "with messages" statement in effect yields 
control to the event loop to check if any "send in time" messages have 
timed out and are pending or to handle other tasks that may have 
accumulated (mouse or keyboard events, etc).


--
 Mark Wieder
 ahsoftw...@gmail.com

___
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


wait 0 with messages

2022-07-30 Thread Paul Dupuis via use-livecode
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?


___
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