OTS ‐ Jumps - Mistium/Origin-OS GitHub Wiki

Control Flow and Conditional Commands Documentation

jump :label_name

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.

Example:

jump :start

:start
# Your code here

calc expression >> var

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.

Example:

calc 10 > 5 >> result
# Compares 10 and 5, stores the result (true or 1) in the variable `result`

All Maths

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

All conditions

* ==      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

if $var :label_name

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.

Example:

if $result :success

:success
# Your code here

Practical Examples

Jumping to a Label

To jump to a specific label within a script:

jump :start

:start
echo "This is the start of the script."

Performing a Calculation and Storing the Result

To perform a comparison and store the result in a variable:

calc 10 > 5 >> result
echo $result
# Outputs: 1 (true)

Conditional Jump

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

Combined Example

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!"

Advanced Tips

  • 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."
⚠️ **GitHub.com Fallback** ⚠️