What is a State?

A state is a collection of statements that are grouped together within square brackets and given a name. An example of a state named "Main" is displayed below.

Main [

  GUIRectangle(236, 180, 280, 236, 

               1, 1, 1, 1, 1 { Scaling }, 

               0, 0 { Movement }, 

               1, 0 { Visibility, scaling }, 

               0, 0, 0 { Selectability }, 

               Brush(0, 0, 1), Pen(0, 1, 1)); 

  GUITransform(232, 236, 288, 180, 

               1, 1, 1, 1, 1 { Scaling }, 

               0, 0 { Movement }, 

               1, 0 { Visibility, scaling }, 

               0, 0, 0 { Selectability }, 

               Variable("AI20_1")\TopBar(222, 0, 100)); 

  Return(Self); 

  GUITransform(164, 256, 336, 168, 

               1, 1, 1, 1, 1 { Scaling }, 

               0, 0 { Movement }, 

               1, 0 { Visibility, scaling }, 

               0, 0, 0 { Selectability }, 

               Variable("Library")\Bitmap(

               "Bitmaps\Tanks\Tank06.bmp", -1)); 

]

This particular state (copied from the code contained in a system page source file) draws a rectangle, an analog input tag as a Top Bar, and a bitmap of a tank on a system page.

It is important to note that the order of the statements in a state does not imply the order in which they are executed; rather, the statements in a state are considered to execute simultaneously. They are all active at the same time.  For example in the preceding code, moving the Return(Self); statement to the line before the GUIRectangle would have no effect.

 

When a state becomes active, all statements within it are executed exactly once.  Whenever a variable's value in a statement changes, all statements that include that variable will be executed again. Similarly, if a graphics statement is used in a state, the appearance of the graphic element on the screen will change as its parameters change. All statements in a state are active while the state is running, and are inactive when the state is stopped. Further, only one state within a module can be active at a time. Please refer to the topic States for more information.

 

The order of statements in a state is significant for only two purposes:

      For graphics where the order dictates the layering of the graphics. The graphics are layered from bottom to top, in the order that the graphic commands are found in the state.

      For keyboard input focus where the operator can step from one input field to the next using the tab key.