# Syntax of expressions in the blocks

To declare variables and set certain values ​​for them, the “[Variable Initialization](/en/studio/programming-visual/blocks.md#variableinit)” block is used.

!["Variable Initialization" block](/files/-M51qy1lrvlast0f4s2z)

For mathematical expressions — "[Expression](/en/studio/programming-visual/blocks.md#expression)" block.

!["Expression" block](/files/-M51s0-8mn_MW1mdTryJ)

Also, mathematical expressions, including those that change the values ​​of variables, can be used almost everywhere where you can specify a value.

Blocks and their properties that do not allow the use of mathematical expressions are described in the section ["Common blocks"](/en/studio/programming-visual/blocks.md#list-of-common-blocks).

All variables in the program are global, i.e. their values ​​can be used in any block in the program.

## TRIK Studio language

The language used inside the blocks is based on [Lua 5.3](https://www.lua.org/) and largely follows its syntax. Nevertheless, there are significant differences, so a full description of the language used in TRIK Studio is given here.

* [Types](/en/studio/programming-visual/expression-syntax/types.md)
* [Tokens](/en/studio/programming-visual/expression-syntax/lexemes.md)
* [Operators](/en/studio/programming-visual/expression-syntax/operators.md)
* [Sensor variables](/en/studio/programming-visual/expression-syntax/sensory-variables.md)
* [Constants](/en/studio/programming-visual/expression-syntax/const.md)
* [Built-in functions](/en/studio/programming-visual/expression-syntax/built-in-functions.md)

## Examples of expressions

Declaration of several variables in one block "[Expression](/en/studio/programming-visual/blocks.md#expression)":

![](/files/-MSi8prlEwpC9EOocyTZ)

The same using ["Variables Initialization" ](/en/studio/programming-visual/blocks.md#variableinit)blocks:

![](/files/-MSi8t4nF2w9Xgt8Aoxo)

Proportional controller for driving along the line using two light sensors for the TRIK platform:

![](/files/-MSi8wQewpjfPlGnAkFc)

An example of using [arrays](/en/studio/programming-visual/expression-syntax/types/array.md) to set the ports of the “Motors forward” block. An array is created with the name `a`, the port `M3` is assigned to the zero element, the first is `M1`, then the contents of the first element of the array are changed to M4, then the resulting array is transferred to the “Ports” property of the “Motors forward” block:

![](/files/-MSi8zGGBZbIYvXgIY0b)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.trikset.com/en/studio/programming-visual/expression-syntax.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
