Arguments and environment
Read command-line arguments and environment values.
Command-Line Arguments
The words after the file name in otter run greet.ot Ada are the program's arguments. They are in the built-in list arguments, and get arguments into a name copies them into a variable of your own.
For example, otter run greet.ot Ada prints Hello, Ada, and otter run greet.ot with no arguments prints Hello, stranger:
Otter
get arguments into args
if length of args is 0
say "Hello, stranger"
otherwise
say "Hello," first of args
.
Environment variables and the current folder are read the same way. A variable that is not set is gone:
Otter
set environment variable "GREETING" to "hi"
get environment variable "GREETING" into greeting
say greeting
get current directory into here
say "Running in" here
Otter keeps some flags for itself, such as -Port, -NoOpen, -h and --version, so they never reach the program. The Command line page lists them.