![]() UJML Language Reference |
Describes the order of execution in UJML.
When a UJML program is loaded two things happen. First, the executable child elements of the program body are processed in the order they occur in the file. Then UJML starts handling events in the order they are fired until the program is unloaded. Any events waiting to be handled when the program is unloaded are discarded.
In practice, the only two executable elements in a UJML program body are the scripting and display elements. See Scripting. The scripting block specifies a series of statements to be executed and the display element specifies visual elements and event handlers that exist for the life of the program. See Visual Elements, Handling Events.
Other scripting and display elements may exist, for example inside of a function or a transition element, but these are not executed until their parent element is executed.
As a UJML program's scripting statements are executed 'branching' will occur, where code in other parts of the program is executed. This happens, for example, when a function is called or a state variable is changed by the scripting code. See Using Functions, State Transitions.
When the code branched to has its own scripting block, this branching can continue with each branch executing other branches until all code paths for the current program state have been executed. How deep this branching goes depends on the complexity of your program and on the current program state.
Explicit branching occurs when scripting code calls a function, causing the code in the function to be executed before control is returned to the calling code. Implicit branching occurs when the scripting code changes a state variable, causing the associated state transition to execute before control is returned to the scripting code. For both explicit and implicit branching the code causing the branch pauses until the branch execution is complete before it continues.
Figure 1. Explicit and implicit branching in UJML
Delayed branching occurs when a delay element is encountered in a state transition or when another UJML program is linked to. See Linking Files. In either case, the code causing the branch continues executing from that point without waiting for the branched-to code. The branched-to code is executed sometime later, in a manner very similar to an event. In the case of a delay element, the associated scripting code is executed when the delay time runs out. In the case of linking, the new program is executed when it is loaded into memory.
After the last code branch is executed, UJML waits for an event to occur and then executes the appropriate event handler when one does. See Handling Events. The code in the event handlers is fired when the event occurs; possibly setting off a new round of branching which must finish before the next event is processed. In this way, a UJML program runs as a series of events that execute code. If no events are waiting to be processed, the UJML program 'idles' until an event occurs.
|
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
|
|
What do you think about this topic? Send feedback!
|