Event Code are MakerPlot-J instructions that run when an event triggers the control. Nearly all controls respond to some event, such as clicking a button, moving a slider, changing text (and pressing enter to lock it in). When in Edit Mode (F9), event code will NOT run.
The code is simply instructions for the Main Interface, Child Interfaces or controls which perform operations including:
•Setting the property of an interface or a control: !backColor=RED !met0.minAlarm=20
•Running an instruction for an interface, the Main processing environment, or a control: !saveSettings [txtSettingsName] !plot.reset
•Creating or assigning a value to a variable: !makeVar varNewMax !varNewMax=100
•Performing a conditional operation (single line): !if [ain0] > [met0.max] !then !bell
•Running a for-loop (single line): !forLoop 1,10,1: ? the Count is & // count 1 to 10 increment of 1, held in & !forLoop 0,4,1: !plot&.reset
•Standard and Post-Fix Math operations can be performed in instructions. !txtAverage={ ([ain0] + [ain1]) / 2 } // standard math !txtAverage={:: [ain0] [ain1] + 2 / } // post-fix math
•Multiple instructions can be performed on a single line, in the if's !then and !else, and in the forLoop by separating instructions with a semi-colon, ;. !bell; ? Warning Will Robinson!
•Control Event Code can respond to specific event triggers and run instructions only based on those triggers, such as the Main Interface: <click>? single click <dblClick>? double click Or toggle controls: <on>? the control is on <off>? the control is off Please see Triggered Event Code for more information.
Event Code may be entered directly in the Interface Editor Window's Event Code textbox which can be opened for a control by pressing F3 while the mouse pointer is over the control or by clicking on a control while in Edit Mode (F9).
The Event Code textbox will turn yellow when any changes are made to it. The textbox will turn white once the box loses focus, such as tabbing off it or clicking elsewhere. Event Code is NOT applied to the control until it turns white (loses focus) to prevent erroneous code from processing while typing it in. Note that MakerPlot-J does allow modifications while actively processing data. While in Edit Mode, F9, processing of code, value updates and some other operations are disabled.
By double-clicking the Event Code textbox, the Event Code Editor will open allowing contextual help in writing instructions.
When a control is activated, the control's Event Code is placed at the top of the Processing Queue for immediate processing.
Event Code for a control may be manually ran using the run instruction. !btnClear.run
Please see the Code Editor Window for more information on using this editor.
Manually Running Event Code
A controls event code can be manually triggered to run by issuing a run instruction.
!btnClear.run
Triggered Event Code
Beyond the standard activation of a control, controls also run code when certain defined triggers occur, such as analog data arriving or a meter alarming. Please see Triggered Event Code for a discussion on coding for triggers. Some controls, such as the Interfaces and Toggle buttons require the use of Triggered Events.
|