Complex
Basic Principles
Complex is a powerful format in Virtel that allows you to combine multiple steps into a single file, simplifying the management of complex projects. Here are the basic principles:
- Multiple commands are combined into one file using curly braces
{}
. - Each command in Complex ends with a semicolon
;
. - Nested blocks are supported, enabling the creation of complex logic structures.
Steps to Rewrite Code
- Define Block Boundaries: Each block starts with
{
and ends with}
. Blocks can be nested to create complex structures. - Replace File References: In Steps, each step is stored in a separate file. In Complex, the code is written directly between curly braces instead of referencing external files.
- Add Semicolons: Ensure that each command ends with a semicolon
;
. - Use Nested Blocks: For loops, conditional statements, or other structures, use nested blocks appropriately.
Examples
Example 1: Simple Counter
Steps Code:
[/start.steps]
scr new text "text" "0" "max/min" root;
var set "0.0" num;
mat eqs num "10000000.0" cond;
bln not cond cond;
run while cond "/iter.steps";
[/iter.steps]
mat plus num "1.0" num;
mat eqs num "10000000.0" cond;
bln not cond cond;
scr set text "title" num;
[end]
Complex Code:
scr new text "text" "0" "max/min" root;
var set "0.0" num;
mat eqs num "10000000.0" cond;
bln not cond cond;
run while cond {
mat plus num "1.0" num;
mat eqs num "10000000.0" cond;
bln not cond cond;
scr set text "title" num;
};
Example 2: HTTP Server
Steps Code:
[/start.steps]
srv new "8080" server;
srv add "get" "/" "/response.steps" slashres server;
srv run server;
[/response.steps]
tts say "Hello!";
str add "Hello, World!" slashres;
[end]
Complex Code:
srv new "8080" server;
srv add "get" "/" {
tts say "Hello!";
str add "Hello, World!" slashres;
} slashres server;
srv run server;
Example 3: Nested Blocks
Steps Code:
[/start.steps]
run if "true" "/if.steps";
[/if.steps]
tts say "Hello!";
[end]
Complex Code:
run if "true" {
tts say "Hello!";
};
Tips for Working with Complex
- Clear Structure: Use nested blocks to organize your code. Each block should have an opening
{
and closing}
. - Proper Semicolons: Ensure that every command ends with a semicolon
;
. - Test Your Code: Test individual blocks regularly to avoid errors.
- Comments: Anything after a semicolon at the end of a file can be used as a comment.
Conclusion
Rewriting code from Steps to Complex makes your programs more compact and easier to manage. Use Complex for complex projects requiring coordination of multiple components, and Steps for simpler tasks.