-
-
Notifications
You must be signed in to change notification settings - Fork 19
OTS ‐ Variables
OTS is now a full-fledged language that allows for scripts to be run through the terminal. One of the key features of any programming language is the ability to use variables. This document will guide you through the use of variables in OTS, including how to define, manipulate, and utilize them in your scripts.
You can define a new variable in OTS using the =
symbol. The syntax is as follows:
varname = value
greeting = hello world
In this example, the variable greeting
is assigned the value hello world
.
You can redirect the output of any terminal command into a variable using the >>
symbol. This is useful for capturing the output of commands and storing them in variables for later use.
ls >> home
This command sets/creates the variable home
with the value of the output of the ls
command, which lists the contents of the current directory.
You can call a variable in OTS using the $
symbol. This allows you to use the value stored in the variable in your commands or scripts.
ls >> home
echo $home
In this example, the output of the ls
command is stored in the home
variable, and then echo $home
prints the contents of the home
variable, which would produce the same output as a normal ls
command.
# Define a variable with a simple string
message = Hello, OTS!
# Print the message variable
echo $message
Output:
Hello, OTS!
# Capture the output of the 'pwd' command (prints the current directory) into a variable
pwd >> current_dir
# Print the current directory stored in the variable
echo $current_dir
Output:
Origin/(C) Users/Username
# List all files in the current directory and store in a variable
ls >> files
# Print the list of files stored in the variable
echo $files
Output (example):
file1.txt
file2.txt
directory1
directory2
# Define two variables
first_name = John
last_name = Doe
# Combine variables to form a full name
full_name = $first_name $last_name
# Print the full name
echo $full_name
Output:
John Doe
Variables in OTS provide a powerful way to store and manipulate data, making your scripts more dynamic and flexible. By using the =
, >>
, and $
symbols, you can easily define, capture, and utilize variables in your terminal commands and scripts. Experiment with these features to enhance your OTS scripting capabilities!
originOS is a web desktop gui with a self contained file system, programming languages, internet system and a whole lot of stuff an os should be able to do Use originOS here