|
MakerPlot-J uses a number of special characters to inform the software what type of processing is to be done. For example, the exclamation mark ( ! ) is used at the beginning of the line to inform the software to expect an instruction. MakerPlot-J is a line processing interpreter. A single line contains the information the software needs for performing operations, conditionals, loops and data. As such, there are no ‘blocks’ of code.
As the software does not use quotes to indicate strings, care should be taken to avoid certain use of these characters, such as using commas or semi-colons in text as they may be processed as special characters.
If you wish to test some with the DEBUG/CLI window (F4 to open), for analog data type in some values first to populate ain0, ain1, etc: 10,20,30,40
If testing text boxes, hit Enter to lock in the value once typing changes in it.
While most characters can be used in text, the following are noted to cause issues in processing text strings, such as for a textbox, label and other text based controls:
•Semi-colons should not be used except to separate instructions
•{ } braces should only be used for math instructions
•[ ] brackets can be used in most situations, but it is recommended to use only for return values when possible.
•Commas should not be used in text where there is a comma-separated parameters lists.
•Starting a string with an equal, = , can cause problems with .add instructions
•While MPJ supports both \ and / in file paths, it is recommended to use / such as: snapshot/lastimage.jpg
The following is a list of special character used in the MakerPlot-J software.
//
|
Indicates comments following instructions and other operations
|
?
|
Used in place of !debug to send information to the DEBUG/CLI window for display. It must be at the start of the line.
|
,
|
Used to separate parameters in instructions, such as: !drawLine 0,0,100,100,RED,10 // draws a line on the main interface from 0,0 to 100,100 in blue with a width of 10
|
!
|
Used at the beginning of an instruction to signify an instruction will follow as opposed to data. Instructions can be performed for the main processing of the interface or with controls.
!debug Hello World! //Used to display information in the Debug/CLI window. !drawFilledCircle 50,50,10,RED // Places a filled circle in the center of the main interface !canvTest.drawLine 0,0,100,100,BLUE,10 // Draws a blue line with a width of 10 diagonally in a Canvas control named canvTest !clearDrawings // Clears all drawing on the main interface !plot.reset // Resets an Analog Plot called plot !makeVar myVal=20 // Creates a variable named myVal and assigns it 20 !makeTextBox txtTest,20,20,30,10,Hello // Creates a textbox named txtTest in upper left with the text of ‘Hello’ !txtTest.backColor=LIME // sets a text box called txtText’s background color to lime.
|
=
|
Used for assignment of properties and variables. Also used in math equations. !control.property = 20 !varVariable = 100
|
@
|
Use at the start of a line to indicate drawing on analog plots, digital plots interfaces and the Canvas control are ‘constant drawings’. This is a second set of drawings from those with created with ! which allows the graphics to remain if clearing or deleting the standard drawing.
@drawFilledCircle 50,50,10,RED // Will not delete with !clearDrawings, but will with !clearConstDrawings
|
;
|
Used to separate instructions on a single line of text for individual processing.
!makeTextBox txtTest2,0,50,30,10,Hello; !txtTest2.backColor=BLUE // create a control and set the background color.
|
[ ]
|
Used to indicate that what is in the brackets is a value to be retrieved and used in processing. The value can be from variables, system or control values, interface and control properties. As MakerPlot-J performs replacement of the values prior to processing, these can be placed in instruction to use interactive data in processing.
? [ain0] // Display analog 0 channel in DEBUG/CLI window. !drawLine 50,50,[ain0],[ain1],RED // draw lines using analog-in data for channels 0 and 1 for X2 and Y2 coordinates. !txtTest.top=[ain0] // Use analog 0 for setting the top coordinate of the textbox ? [txtTest.top] // Display the top coordinate value of the text box. ? [myVal] // Display the value of variable myVal !txtTime=[systemTime] // Set a textbox value to the computer’s time
|
[this] !this. [this. [[this]]
|
When writing a control’s Event Code – code it runs when some action occurs, such as clicking a button – [this], !this. and [this. ] will all replace ‘this’ with the name of the control running the code. This allows a control’s name to be changed without affecting it’s code, or to make it easier to create generic code for copy/paste operations. [[this]] will return a control’s default property value, such as a slider’s setting.
To place a control for testing Open the Control Palette with CTRL-P, click a Button Control, answer the questions, then place on main interface. Place mouse over the button and press CTRL-E to open the Interface Editor, the Event Code is at the bottom. You can copy and paste the code below.
? You activated control [this] // Display text to DEBUG/CLI !this.backColor=RED // Change this control’s back color ? [this.backColor] // Display this controls back color ? The value of [this] is [[this]] // Display name and value of a control when activated
|
:
|
Used only in defining RGB colors and indicating post-fix math operations (below). Colors such as 200:50:100, which, on a scale for each of 0 to 255, means 200 for red, 50 for green and 100 for blue – the higher the brighter for each. This allows colors to use decimal values, which may come from incoming data, such as [ain0]:[ain1]:[ain2]
!txtTest.backColor=200:100:0 // Sets color to decimal RGB value !drawFilledCircle 50,50,20,[ain0]:[ain1]:[ain2] // Create a filled circle on the main interface using analog data for color
Note that colors also support names (constant names such as RED, BLUE, etc) and RGB hex values: 0xff80A0 See Colors for more information
|
< >
|
Used in Event Code to process the code of special event triggers for that control. All controls and interfaces have the <load> trigger which runs when !runLoad is issued – It is included at the end when an interface file is saved. Some other events include <click> for a mouse click, <high> when a high alarm for a meter is triggered, and many more. The code will only be run when the particular trigger is relevant to the triggering event and other code in the event will not be processed.
|
{ }
|
Braces denote a standard math operation to be performed. MakerPlot-J values, such as data or control properties, may be used. ? { sin(rad(90)) * (2 + 2) } // Display results of the math operation ? { sin(rad([ain0]) * [txtTest] } // Display results of the math operation See Standard Math for more on math operations.
|
{:: }
|
Braces with leading colons indicates a Post-Fix Math operation. These extend the standard operations and provide for string process. Post-Fix Math operates by first entering data then stating the operation to use on the data:
? {:: 2 5 * 2 +} // Display results of 2 * 5 + 2 ? {:: [ain0] 8 10 + * } // Display results of 8 + 10 * analog 0
Standard Math and PF Math may be mixed: ? { sin(rad(90)) * {:: [ain0] 8 10 + * } } See Post-Fix Math for more on operations.
|
::
|
Used with post-fix math string operations to separate parameters that contain spaces. ? {:: Hello World!::World::Universe::replace}
|
''
|
Two single-Quotes. Special case to prevent processing of data until selected of information following the ''. Analog Channel 0 ''[ain0]
|
|
|