top of page
Why hello there! Find out the TheBasics of Bricx Command Center Here!
Operators


Before learning about if statements and while loops, one must learn the operators involved in using these statements.
These operators are used to compare values such as intergers.
Conditions and Loops - The While Loooooooop and Repeat Statement
The while loop like its name suggests repeats commands within its curly brackets while the conditon of the while loop is true.
Format: while (condition) { ...commands here...}
Example: check sample code
This code can be done more efficiently by using a repeat statement. It is like the while loop without the condition.
Format: repeat(# of loops you wish){ ...commands here...};
Example: repeat(10) { ...commands here...}
Note: while(true) is a infinite loop
Conditions and Loops - The If Statement and Until Statement
The If statement is similar to the while loop in that they both have conditions, however the difference is that the If statement does not repeat any of the commands.
Format: if (condition) { ...commands here...}
Example: check sample code
If the condition is true, the code within the curly brackets are executed and the program will move on to the code after the second curly bracket.
If the condition is not true the program will check the next conditon if there is one. If there is no conditon after the first conditon, the program will move on to the commands after.

The until statement waits until the condition between the round brackets is true, therefore the statement waits until condition is met and then moves on to finish the program.
Works somewhat like the if statement.

bottom of page