First of all, what does syntax mean? I'm too dumb to explain it myself so i'll quote wikipedia :trollface:
How does that relate to SB? Well, sanny can understand and compile code in two syntaxes;
- Low level coding/statements
- High level coding/statements
Low level is mostly relying on labelsstart, @start, jump @start, jf @start)
It's messy and hard to understand if you code is bigger or more complex.
It's also the way sanny outputs decompiled scripts.
Example;
High level is logical, simpler to use and easier with bigger and complex scripts. It also looks more clean.
Example;
They basically work the same, there's nothing you can do in one and not the other. It all depends on how easier each one is for you. If you're new to cleo scripting i suggest using a mix of both.
Low level statements:
Defines the name and start of the label.
Like said above low level is based on labels, so naming them is important, also you can't have more labels with the same name.
Intrerupts the flow of the script by jumping to given label.
Conditional check, to be used with a condition. If the condition is false then intrerupts the flow of the script and jump to given label.
High level statements:
Every script is one big loop, and can contain more loops, loopception. :face_palm:
You'll be using this for the main script mostly. It's a simple loop which repeats infinitely.
Conditional check, while condition is true repeat everything in a loop until condition is false.
Condition is read first, if condition is true the loop won't be executed.
Repeats everything in a loop until conditon is true.
The loop will only execute once.
The loop will execute infinitely untill the loop is stopped.
You'll be using these a lot in your script. They're condition checks.
This will loop only for a number of iterations.
break - is used to break the current loop.
continue - is used to jump to the next condition check/iteration.
You can use break and continue in low level coding too;
BREAK and CONTINUE can be only used inside of a loop.
Sorry for any mistakes, either code or grammar. Point them out in the comments and i will fix them.
In linguistics, syntax is "the study of the principles and processes by which sentences are constructed in particular languages."
How does that relate to SB? Well, sanny can understand and compile code in two syntaxes;
- Low level coding/statements
- High level coding/statements
Low level is mostly relying on labelsstart, @start, jump @start, jf @start)
It's messy and hard to understand if you code is bigger or more complex.
It's also the way sanny outputs decompiled scripts.
Example;
High level is logical, simpler to use and easier with bigger and complex scripts. It also looks more clean.
Example;
They basically work the same, there's nothing you can do in one and not the other. It all depends on how easier each one is for you. If you're new to cleo scripting i suggest using a mix of both.
Low level statements:
Code:
:label
Like said above low level is based on labels, so naming them is important, also you can't have more labels with the same name.
Code:
jump [member=23507]Label[/member]
Code:
jf [member=23507]Label[/member]
else_jump [member=23507]Label[/member]
jump_if_false [member=23507]Label[/member]
High level statements:
Code:
while true - end
do i even make sense? :dont_care:
Code:
while - end
Condition is read first, if condition is true the loop won't be executed.
Code:
repeat - until
Code:
repeat - until true
Code:
repeat - until false
Code:
if - then - else - end
Code:
for - end
Code:
for var@ = <start val> TO/DOWNTO <end val> step <n>
Code:
BREAK and CONTINUE
continue - is used to jump to the next condition check/iteration.
You can use break and continue in low level coding too;
Code:
jf BREAK
jf CONTINUE
Sorry for any mistakes, either code or grammar. Point them out in the comments and i will fix them.