This article is automatically translated from Russian by Google Translator.
TRIK Studio Junior blocks consist of four categories:
Algorithms — blocks to describe algorithms.
Actions — blocks that perform any action on the "Character movement": commands to drive forward, turn, play sound, and others.
Waiting — blocks waiting for an event to occur: certain sensor readings, pressing a button, etc.
Drawing — blocks displaying graphics and text on the screen.
The starting point for program execution.
Each diagram should have only one such block. There should not be any incoming links in it, and there should be only one outgoing link from this element.
The process of diagram interpretation begins with this block.
End of the program.
If the program consists of several parallel execution sections, reaching this block completes the corresponding execution section.
This block cannot have outgoing links.
A block for declaring a new variable and setting a value for it. The same operation can be performed using the Expression block, but this block makes the program more clear.
Separation of program execution in accordance with a given condition.
This block must have two outgoing connections, at least one of which must have the value of the Condition parameter set: true or false.
Indicates merging of two branches of a conditional statement. It does not perform any actions but is useful for ensuring the structure of the program.
It does not perform any actions but is useful for ensuring the structure of the program. If you adhere to the rule that all branches of the "Condition" or "Switch" operators converge on such a block, this will significantly increase the chances that the generator will be able to generate code in text language without goto
statements.
A loop with a precondition is a loop that is true so far for some conditions specified before it starts. This condition is checked before the loop body is executed, so the body may not be satisfied even once (if the condition is false from the very beginning).
Block that provides the execution of a sequence of blocks several times.
The number of repetitions is set by the value of the Iteration parameter. The block must have two outgoing connections, one of which must be marked with the value “body” (that is, the value of the “Condition” parameter the connection must have “body”). Another connection coming from the “Cycle” block should remain unmarked: it will go through when the program passes through the “Loop” block the specified number of times.
Infinite loops and loops of the form while / do
and while
are organized without using this block, looping the control flow using links. An exit from such a loop is carried out using the “Condition” block.
A condition with several alternatives.
In the "Expression" parameter, you can specify an arbitrary expression (for more details, see the section "Syntax of expressions"), based on the value of which the further path of the diagram interpretation will be selected.
This block must have several outgoing links. All relations, except one, should be marked with an elementary value (string, number, etc.), which can take an expression (the value is simply written in the Condition property of the connection). One of the links should not be marked: it jumps if the expression is not equal to any of the listed values.
Evaluate the value of the specified expression. Initialization of variables is also allowed.
For more information about the syntax of valid expressions for the Expression parameter, see the section "Expression syntax".
Subprogram execution. Subprograms are used to keep repeating program fragments on a separate diagram. When adding this block to the diagram, you will be prompted to enter the name of the subprogram, after which double-clicking on the block will be able to go to the diagram corresponding to this subprogram. An additional palette with all the subprograms will also appear. Subprograms from it can be dragged onto the scene and used as normal blocks. The appearance, name, and properties of the block can be changed using the context menu.
Changing the properties of this block does not perform in the "Properties Editor" panel, but using the "Change Properties" item in the context menu. To call the context menu, right-click on the block "Subprogram".
In the window that opens, you can:
Change subprogram name.
Add and change subprogram parameters by specifying a name, type, and value.
Change the picture on the icon of your subprogram.
Change subprogram icon background.
A block divides program execution into several threads. For example, you can simultaneously wait for the sensor to trigger and the time interval to expire.
A block must have at least two outgoing connections.
In order to be able to further refer to parallel tasks generated by this block (for example, in the "Kill thread" block or in the "Join" block), you need to give the names of the tasks. This is done on outgoing connections, in the Condition property. The name of the task can be any string, but one of the names should be the name of the task that is included in this block. The name of the main program is main
.
Block for merging parallel tasks.
It blocks the execution of the program until the execution of all parallel tasks included in this block reaches this block.
A block must have at least two incoming links. On the outgoing connection (in the “Condition” property) there must be an identifier for the task, which will continue after the block has completed.
Finishes the task with the identifier specified in the "Task" property. Must be applied from another task.
A block for assigning a specified variable to a random integer from a specified interval using the From and To properties.
Block for adding arbitrary text to the diagram as a comment.
Used to explain a specific block or section of a diagram. May be associated with the block, which he explains.
When the program is executed, the block is not taken into account.
Sends the message to a parallel task with a specified identifier (the identifier must be specified while creating the task in the "Fork" block).
The message can be arbitrary.
Assigns the pressed button code to a specified variable.
The "Waiting" property allows you to wait for the button to be pressed. If the button is not pressed, the variable will be set to -1.
Moves the "Character movement" forward by the specified number of cells.
The "Number of cells" property allows you to set the number of cells the "Character movement" should move by.
Moves the "Character movement" back by the specified number of cells. The "Number of cells" property allows you to set the number of cells the "Character movement" should move by.
Turns "Character movement" to the right.
Turns "Character movement" to the right.
Use the speaker to say the phrase passed as the block argument.
Set the specified LED color on the controller.
Block for setting the delay. The delay time is set in the Delay parameter in milliseconds.
Wait for a message from another parallel task.
The message text will be assigned to the specified variable.
The "Wait for message" property allows you to specify what to do if the message queue is empty: wait for a new message to arrive or continue working by assigning an empty string to the variable.
The message is automatically converted to the same type as the receiver variable. For example, if you send a number as a string, it will be accepted as a number.
Wait for the user to enter a value. The value will be assigned to the specified variable.
The block has three properties:
Example
Wait until the specified button on the robot is pressed.
Erase everything that is drawn on the screen.
Start drawing with a marker of a given color on the floor. When the robot moves in a two-dimensional model, a colored line will remain behind it.
The block is available only in the two-dimensional model mode.
Finish drawing with a marker.
The block is available only in the two-dimensional model mode.
Prints the specified string at the specified location on the robot's screen.
To print a text:
Put your text into the Text property.
Uncheck the Evaluate checkbox.
To print a variable value:
Put the variable name into the Text property.
Check the Evaluate checkbox.
Specify the color to draw simple graphical shapes on the robot's screen.
Specify the width of the line used to draw simple graphical figures on the robot's screen.
Draw a dot on the screen at the specified coordinates.
Draw a line segment on the screen. Segment ends are given as parameters to the block.
Draw a rectangle on the screen. The coordinates of the upper left corner, the width, and the height of the rectangle are specified as parameters.
Draw an ellipse inscribed in a given rectangle on the screen.
Draw an arc on the screen, given the coordinates of the rectangle in which it will be inscribed, and the angles (in degrees) of its beginning and end on the circle. If the beginning and the end coincide, the circle will be drawn.
Draw a smiley face on the screen.
Draw a sad smiley face on the screen.
Sets the screen background color.
Property
Description
Value
An expression is specified that defines the initial value of the variable.
Variable
The variable name is specified.
Property
Description
Condition
A logical expression is indicated (for more details, see the article "Expression Syntax"), based on the value of which the further path of the diagram execution will be selected.
Property
Description
Condition
The logical expression is specified (for more details, see the article "Syntax of expressions"), based on the value of which the further path of the diagram interpretation will be selected.
Property
Description
Variable
Variable name.
Default
Default variable value.
Text
Text field description.
Property
Value
Evaluate
True — print the variable or expression value.
False — print as text.
Text
Text or variable/expression to be printed.
Redraw
True — redraw the screen. False — do not redraw.
X, Y
The text beginning coordinates.
Icon
Name
Description
The starting point for program execution.
Each diagram should have only one such block. There should not be any incoming links in it, and there should be only one outgoing link from this element.
The process of diagram interpretation begins with this block.
End of the program.
If the program consists of several parallel execution sections, reaching this block completes the corresponding execution section.
This block cannot have outgoing links.
A block for declaring a new variable and setting a value for it.
Separation of program execution in accordance with a given condition.
Indicates merging of two branches of a conditional statement. It does not perform any actions but is useful for ensuring the structure of the program.
A loop that is executing so far some condition is true, indicated before it begins. This condition is checked before the loop body is executed, so the body may not be satisfied even once (if the condition is false from the very beginning).
Block that provides the execution of a sequence of blocks several times.
A condition with several alternatives.
Counts the value of the specified expression. Initialization of variables is also allowed.
Subprogram execution.
Block divides program execution into several threads.
Block merging parallel tasks.
Finishes the task with the identifier specified in the "Task" property. Must be applied from another task.
A block for assigning a specified variable to a random integer from a given interval.
Block for adding arbitrary text to the diagram as a comment.
Icon
Name
Description
Sends the message to the parallel thread with the identifier given.
Saves the code of the button pressed on the robot to the specified variable.
Moves the "Character movement" forward by the specified number of cells.
Moves the "Character movement" back by the specified number of cells.
Turns "Character movement" to the right.
Turns "Character movement" to the left.
Speak through the speaker the phrase passed as an argument.
Set the specified controller's LED color.
Icon
Name
Description
Block for setting the delay. The delay time is set in the Delay parameter in milliseconds.
Wait for a message from another parallel task.
Wait for the user to enter a value.
Wait until the specified button on the robot is pressed.
Block
Execution
Icon
Name
Description
Erase everything that is drawn on the screen.
Start drawing with a marker of a given color on the floor. When the robot moves in a two-dimensional model, a colored line will remain behind it.
Finish drawing with a marker.
Print the specified string at the specified location on the robot's screen. The default value of the "Text" property is interpreted as a pure string, so it will be displayed that way.
Specify the color to draw simple graphical shapes on the robot's screen.
Specify the line width used to draw simple graphical figures on the robot's screen.
Draw a dot on the screen at the specified coordinates.
Draw a line segment on the screen. Segment ends are given as parameters to the block.
Draw a rectangle on the screen. The coordinates of the upper left corner, the width, and the height of the rectangle are specified as parameters.
Draw an ellipse inscribed in a given rectangle on the screen.
Draw an arc on the screen, given the coordinates of the rectangle in which it will be inscribed, and the angles (in degrees) of its beginning and end on the circle. If the beginning and the end coincide, the circle will be drawn.
Draw a smiley face on the screen.
Draw a sad smiley face on the screen.
Set the screen background color.