OTS ‐ Jumps - Mistium/Origin-OS GitHub Wiki
The jump
command allows you to jump to a specific label within a script. This is useful for creating loops or for conditionally executing parts of your script.
jump :start
:start
# Your code here
The calc
command performs a calculation or comparison and stores the result in a variable. Replace expression
with your calculation or comparison, and var
with the variable name where the result will be stored.
calc 10 > 5 >> result
# Compares 10 and 5, stores the result (true or 1) in the variable `result`
Any operator/expression on the page below is able to be run using the calc command in ots:
https://github.com/Mistium/Origin-OS/wiki/OSL-%E2%80%90-Operators-and-Expressions
* == case insensitive equality
* != case insensitive inequality
* > greater than
* < less than
* >= greater than or equal to
* <= less than or equal to
* !> not greater than
* !< not less than
* in string in string
* notin string not in string
* === case sensitive equality
* !== case sensitive inequality
The if
command checks the value of a variable and jumps to a label if the condition is true. Replace $var
with the variable you want to check and :label_name
with the label you want to jump to if the condition is met.
if $result :success
:success
# Your code here
To jump to a specific label within a script:
jump :start
:start
echo "This is the start of the script."
To perform a comparison and store the result in a variable:
calc 10 > 5 >> result
echo $result
# Outputs: 1 (true)
To check a variable's value and conditionally jump to a label:
calc 10 > 5 >> result
if $result :success
jump :failure
:success
echo "Condition met, jumping to success label."
:failure
A combined example demonstrating all three commands:
# Start of the script
jump :start
# A label named start
:start
echo "Performing comparison..."
# Perform a comparison and store the result
calc 10 > 5 >> result
# Conditional jump based on the result
if $result :success
# This part is skipped if the condition is met
echo "This will not be printed if the condition is true."
:success
echo "Printed!"
-
Looping: You can create loops by using
jump
and labels:count = 0 :loop echo "Count is" $count calc $count < 5 >> continue_loop if $continue_loop :increment jump :end :increment calc $count + 1 >> count jump :loop :end echo "Loop ended."