If statement and more math operators
The if statement is similar to most coding languages.
So if you've coded before you already know how to.
But we are gonna learn anyways.
Here is an example of the if statement.
Code example:
Ok so imagine i have already assigned a value to the variable variable.
This value will be 'value'.
So now it will see if variable is equal to 'value'.
If it is it is gonna execute the commands in the curly brackets.
Now if variable is equal to 'val' then it is not gonna execute the commands in the curly brackets.
Why? Because 'val' is not equal to 'value'.
You can also do the if statement with numbers and math operations.
Code example:
Since 1+2 is equal to 3 it will execute the commands in the curly brackets.
What if the 1 was a 2.
It would have not executed the code because 2+2 is equal to 4 not 3.
So if you've coded before you already know how to.
But we are gonna learn anyways.
Here is an example of the if statement.
Code example:
- if variable='value'
- {
- message_box('do this')
- }
Ok so imagine i have already assigned a value to the variable variable.
This value will be 'value'.
So now it will see if variable is equal to 'value'.
If it is it is gonna execute the commands in the curly brackets.
Now if variable is equal to 'val' then it is not gonna execute the commands in the curly brackets.
Why? Because 'val' is not equal to 'value'.
You can also do the if statement with numbers and math operations.
Code example:
- if 1+2=3
- {
- message_box('is equal to 3')
- }
Since 1+2 is equal to 3 it will execute the commands in the curly brackets.
What if the 1 was a 2.
It would have not executed the code because 2+2 is equal to 4 not 3.