Normal Topic Timing of Events (Read 968 times)
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Timing of Events
Feb 22nd, 2004 at 6:51pm
Print Post Print Post  
I have been experimenting with CurrentElement() and it appears that if I use CurrentElement() in ElementExit Event, that the CurrentElement() value may come back as the next Element as directed by the program vs. the "real" current element where these program lines are originating from.

Example: Elements: One, Two, Three.
Programming in ElementExit event in element Two, may bring back the value of "Three" when I expect it to be "Two".

I have also come to the understanding that ElementExit Events are fired before ElementChange Events.   And ElementChangeEvents can be triggered by programming in other elements

And when does the Current Element value change..before any of these events, after all of them, or somewhere in between any of them, or during them? 

A thorough understanding of this timing is criticial to efficient programming.  What would be useful is a timing diagram that shows the sequence of firing activities for all of the Form/Element Events and the instructions inside each one, and the changing of CurrentElement() value.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Timing of Events
Reply #1 - Feb 22nd, 2004 at 7:57pm
Print Post Print Post  
In GUI (Graphical User Interface) programming, the "ideal" is "State Programming". That is, programming with as little regard for the order of individual "events" as is possible. The theory being that events may, and often do, come in arbitrary, cached or cancelled, states - and should depend on each other as little as possible. This approach, as far as it can be taken, eliminates the vagaries associated with the arbitrary actions of a user with a "random access" input device - such as a mouse.

To give you an example, many GUIs produce exit events on one widget after producing the enter event on another. And while this may seem counter-intuitive, it provides the advantage of being able to know, in the exit event, the value and state of the "entered" widget. That way a decision may be made in the code based on the location of arrival, in the code run on exit.

In other systems, the exit event runs before the focus is moved into another widget, yet after it has left the "exiting" widget, providing a kind of "limbo" state - in which no widget has focus. Yet in others, the exit runs first, then the enter. In every case, the "state" programmer assumes nothing, but attempts to determine the state of the data and the program, as opposed to counting on one event being dependant on another event. That way, should different systems (GUIs) be used (as is the case in Sesame - which runs on both Windows and X11), or should one widget provide entirely different event sequences than another, or the underlying system change (as it did between 3.1 and 95), or should some events be generated by actions outside the application (such as clicking on MSWord while focus is on a widget in Sesame), the program is prepared to receive events in arbitrary order.

And, while attempting to determine event order in Sesame may well produce some efficiencies, if rigidly adhered to and assumed, it will create problems should that order change, whether due to a bug fix in Sesame, or FLTK, or Windows, or X11, or simply due to popular demand.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Timing of Events
Reply #2 - Feb 22nd, 2004 at 9:48pm
Print Post Print Post  
Very interesting as a philosophy Mark, but what can I use to plan with in Sesame?  Are you saying that I cannot know what the sequence will be?  I can't believe that it will be random.

In Q&A it was important to know the sequence of events of Programming and Navigation commands.  There were just six events.   Sesame only has one more programmable event.  Now that Navigation commands are imbedded with Programming I think it is important to understand the execution sequence of the seven Form/Element events

I have spent many hours trying to understand the sequence of events, is this a total waste of time to try to do that?

If I change a value in a field and tab to the next field, which commands fire first, the ElementChange events or the ElementExit events?  If I move to the next field with a Mouse vs. Tab, what is the sequence of events?

The CurrentElement() values appear to change while still executing commands from the originating element, what happens to make that value change?

I am sure there are many underlying events that we cannot program.  Events like GetFocus, LoseFocus, MouseUp, MouseDown, DoubleClick, etc.  We may not be able to program with them, but I think we should still know what they are, the logic behind them, and their interaction with triggering event program commands.

Perhaps another reference from FLTK can be used?  Thanks for listening.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Timing of Events
Reply #3 - Feb 23rd, 2004 at 3:59am
Print Post Print Post  
Quote:
A thorough understanding of this timing is criticial to efficient programming.  What would be useful is a timing diagram that shows the sequence of firing activities for all of the Form/Element Events and the instructions inside each one, and the changing of CurrentElement() value.  



If this is of any value, this is the sequence of events triggered during my preliminary test.

Global Event Triggered
On Form Entry Event Triggered
On Element Entry Event Triggered
On Immediate Element Event Triggered
On Element Exit Event Triggered
On Element Changed Event Triggered
On Form Change Event Triggered
On Form Exit Event Triggered

First I created Static Global variable in the Global code and assigned value to it

stat vGlobalEvent as String
vGlobalEvent = "Global Event Triggered"
Writeln (vGlobalEvent)

I have two LEs in in my EventTimer.db and each event has the same variable assigned the value stated above.

==========
On Form Entry Event

var vEventTrigger as String
vEventTrigger = "Element Entry Event Triggered"
WriteLn (vEventTrigger)

=============
On Element Exit Event

var vEventTrigger as String
vEventTrigger = "Element Exit Event Triggered"
WriteLn (vEventTrigger)

==============
Just like this assign the value to variable for each event and just sit back and watch the event firing after one another.

I heard Mark saying, he would like to have flexibility to change this event sequences if necessary and he would like us not get too hung up on this sequences.


  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Timing of Events
Reply #4 - Feb 23rd, 2004 at 5:58am
Print Post Print Post  
Thanks for your input Bharat_Naik.  It looks very similar to my tests also, but there still seem to be some underlying actions that I would like to get a handle on.

I have taken a similar approach, using WriteLn without variables but including Current Element.  I got into this because of trying to do some conditional IF instructions based on the current element, and found that I was no longer in the "current element" when the next commands were called.  It took quite a while to understand what was happening.

For analysis purposes, for the first instruction in each event, I entered the single command   Quote:

WriteLn("Firing event for ElementEntry Event for element "+@CurrentElement())
changing the BoldedEventName for the appropriate Event.

What is surprising is that the Current Element may change before all instructions have been completed.  Also try adding some GOTO commands to force a flow different from the "normal" left to right/top to bottom flow.  Also try moving between fields with Tab/Enter keys, and then random field selections jumping around to fields.

Other unanswered sequences:  When a programming command changes the value of another element, what actions are triggered in that element?  And are they done before or after the rest of the commands in the current element? 

I think it is going to be possible to do more analysis to discover the answers, but If Lantica can provide the answers we can spend our time on more productive issues.  I want to be able to spend the time developing the application coding, not troubleshooting to understand why I get unexpected results.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Timing of Events
Reply #5 - Feb 23rd, 2004 at 1:28pm
Print Post Print Post  
I'll see what I can do to clarify the events.

Be very careful, especially using "WriteLn" in that bringing up the Writeln window and writing to it, can change the control flow in Sesame and alter your results. It would be more accurate to use the file I/O operations and then view your results after the experiment is complete.

Additionally, as in Q&A, the mouse combined with the GOTO statement produces the events of both. If you have a GOTO in an on exit for a LE, and the user leaves that LE to go to another using the mouse, the GOTO statement fires, forcing control flow (but not focus) to the subject of the GOTO statement. This is as it is in Q&A. If that LE also has a GOTO in its code, control flow and focus follow that GOTO - unlike Q&A, where flow follows the secondary GOTO (I think), but focus still follows the mouse.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Timing of Events
Reply #6 - Feb 23rd, 2004 at 11:08pm
Print Post Print Post  
Quote:
I'll see what I can do to clarify the events.
Thanks Mark, that sounds real promising. Grin  Grin

The only tool I saw to help troubleshoot was the WriteLn, no way to Single Step and see variable values.   And now you've given me a good reason to learn the "new" file i/o commands.  One more thing to experiment with.....it never ends!  Smiley
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Timing of Events
Reply #7 - Feb 23rd, 2004 at 11:20pm
Print Post Print Post  
If you are just experimenting, you can also use a GlobalValue or a global variable to accomplish the same thing. As you receieve events concat strings into the variable. Then when you are done use a single record mass update to write it to the Writeln window.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged