Scripts
The focus here is on script.
1. About the TOMATE Script
The TOMATE script provides the following unique commands.
Classification | Contents |
---|---|
[ ] | Show variables |
< > | Move page |
( ) | Variable operation |
xxx{ } | Commands |
” “ | Output to “OUTPUT.TXT” |
Use the following symbols as delimiters:
Separator | Contents |
---|---|
: (colon) | Command delimiter or Separate items in commands |
, (comma) | Separation of setting values in commands. |
Multiple commands can be used for one object by separating each command with a colon “:”.
Example:
(cnt+=1) : <@next> : "Next page"
When an object is touched, cnt+=1, move to the next page, and output 'Next page' strings to "OUTPUT.TXT" file.
Basically, there is no need to distinguish between character strings and numeric values for characters handled in the TOMATE script.
Using single quotes ‘ ‘ treats everything as a string, including numbers.
Parentheses, commas, and colons used in the TOMATE script must be enclosed in single quotes when used in strings.
There are two types of TOMATE scripts.
Content | Script reference icon |
---|---|
What is reflected in the constant display | |
Execute when touch operation or input to “INPUT.TXT“ |
About the Script Reference
For more information on scripts, see “Script Reference”.
It is displayed by specifying “Help: Script Reference” from the app menu.
2. Script reflected in display
Let’s actually create it.
Draw a suitable object and write [cnt] in the script field of that object.
This will display the value set in the variable cnt within that object.
The script [variable name] is a command that displays the variable value.
If you use a variable in your script, enter the variable name in the “Variables” area.
In the variable field, you can enter the initial value of the variable with ‘=’.
If the variable value contains only numbers, it will be treated as a numerical value, and if it contains a character string, it will be treated as a character string.
Enter “cnt=0” here.
The variable settings are a=b=c=0, etc.
A variable name can be written continuously with an equal sign.
Initialized to the value written to the end.
Entering an initial variable value will change the string in the drawn object to that variable value.
At this time, the character format displayed in the object will be the format set in the “Information Tool”.
3. Script reflected in touch behavior
Now let’s write a script for touch actions.
Draw a button object and enter the following in the script field.
(cnt+=1):var{cnt:1}
Parenthesized script (expression)
A command that performs variable operations.
TOMATE only uses the assignment operations such as ‘+=’ and ‘-=’.
The left side is always a variable, that is no need to enclose it in [ ] .
When writing a variable on the right side, it is necessary to enclose it in [ ].
The command of ‘var{ }’
This command outputs variable values to ‘OUTPUT.TXT’.
If you put the ‘:1’ flag inside like ‘var{cnt : 1}’
Output with variable name.
Each time this object is touched (clicked), it is cnt+1, and the display value of the display object changes according to the change of cnt.
4. Test run
When the creation is complete, press the tool button or operate “Menu: Run: Test” (F5 key).
A test window will appear, and each time you press the PUSH button on the screen, the display will increase by one.
Furthermore, the value of the variable cnt is displayed in the ‘Output.txt’ field of the I/O window.
4-1. Input/Output interface
TOMATE can communicate with external programs using two files, Input.txt / Output.txt, as an external interface.
These two files are automatically created in the folder where TOMATE is running.
Input.txt | Interface for inputting commands to TOMATE from external program. |
Output.txt | Interface for outputting information from TOMATE to the external program. |
By reading the contents of ‘Output.txt’ from an external program, you can read the operation contents and variable contents on TOMATE.
You can also issue instructions to TOMATE by writing commands to ‘Input.txt’ from an external program.
In the I/O window, you can check the contents of ‘Output.txt’, write commands to ‘Input.txt’, and check the operation.
Only commands marked with an icon in the script reference can be written to ‘Input.txt’.
For example, enter ‘msg{Hello}’ in the ‘Input.txt’ field and press the [Write] button.
A message box with ‘Hello’ will open on the ‘Test window’.
The command of ‘msg{ }’
It is a command that can easily display a message.
You can arbitrarily set the number of buttons and characters to be displayed on the buttons.
If nothing is specified, only the [OK] button will be displayed.
The message box is disappeared when the button is pressed.