Ohio supports the following data types:
alpha- Integer values (e.g.,int age = 25;)beta- Decimal (floating-point) values (e.g.,dec pi = 3.14159;)rizz- Boolean values (trueorfalse)gamma- Single character values (e.g.,char letter = 'A';)
- Variables must be declared before use.
- Only lowercase letters are allowed for variable names.
- Example:
alpha x = 10; beta pi = 3.14; rizz is_valid = true;
- Global constants must be declared outside
code {}.- Example:
<< a global variable >> beta pi = 3.14159; code { << a local varible >> beta radius = 10.0; }
- Example:
- Arithmetic:
+,-,*,/,% - Comparison:
==,!=,>,<,>=,<= - Assignment:
= - Exponent:
e
flip () {
<< true case code >>
} twist() {
<< else if case code >>
} flop() {
<< false case code >>
}
Example:
flip (x > 0) {
echo("x is positive");
} twist (x < 0) {
echo("x is negative");
} flop {
echo("x is 0");
}
- While Loop:
spin (condition) {
<< Code block >>
}
Example:
alpha i = 0;
spin (i < 5) {
echo(i);
i = i + 1;
}
- Printing to Console:
echo("Hello, World!");
- User Input:
alpha age = capture("Enter your age: ");
- Single-line comment:
<< This is a comment >> - Multi-line comment:
<<<
This is a multi-line comment.
>>>
- Functions must be declared before use.
- Example:
func add(int a, int b) {
return a + b;
}
alpha result = add(5, 3);
echo("Sum:", result);
- Main block of code is enclosed in
code{}. - Proper indentation is recommended but not required.
<< Calculate area of a circle >>
beta pi = 3.14159;
code {
alpha radius = capture("Radius: ");
beta area = pi * radius * radius;
flip (area > 50) {
echo("Large circle");
} flop {
echo("Small circle");
}
}
- Ohio files should use the
.ohioextension.
- The program ends automatically at the last line unless explicitly stated.