Add flow control to readme

This commit is contained in:
suchmememanyskill 2020-04-01 20:55:49 +02:00 committed by GitHub
parent d81ee19628
commit 6de44a69df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,3 +55,37 @@ There are some built in variables:
- `@ISDIRVALID`: Is the open directory valid
- `$FILENAME`: Represents the current filename
- `@ISDIR`: 1 if the last read file is a DIR, otherwise 0
## Flow control
You can use `if()`, `goto()`, `check()` and `math()` functions to control the flow of your program. Example:
```
@i = setInt(0);
?LOOP;
@check = check(@i "<=", 10);
if (@check){
@i = math(@i, "+", 1);
printInt(@i);
goto (?LOOP);
}
```
This will print numbers 0 to 10 as `@i: x`
Another example:
```
printf("Press a button");
pause();
if (@BTN_VOL+){
printf("Vol+ has been pressed");
}
if (@BTN_VOL-){
printf("Vol- has been pressed");
}
if (@BTN_POWER){
printf("Power has been pressed");
}
```