Opihi is a generic command-line interpreter which has been used as the front-end for Mana. The interpreter has a variety of features of shell-scripting languages: if statements, for loops, macros with command-line arguments, and so forth. The shell also allows for variables, arithmetic on variables, input from source files, and a variety of other useful tools. I have used the Opihi shell language for several other user interface front ends, in addition to the Mana data analysis tool: a CCD controller interface and a variable star database in the LONEOS project. The programming structure of the Opihi front-end makes it very easy to add commands to the package; more about this later.
The command-line interaction is based on the readline libraries and behaves like tcsh. Arrows can be used for editing. There is both command and file completion with the TAB key. Multiple commands can generally be placed on one line with semi-colons as separators.
Scalar variables in Opihi are proceeded with a dollar sign ($). A
variable may be created and the value assigned by a line which looks
like:
$var = (expression)
where (expression) is
some math expression. The math expression may consist of the standard
math operators (+,-,*,/) as well as any already-defined variables and
the functions log(), ln(), sqrt(), exp(), ten() (
), sin(),
cos(), etc. Also, if there is a pair of curly brackets {} anywhere
on a command line, whatever is inside is assumed to be a math
expression and evaluated as well. This later feature allows functions
of variables to be passed as arguments to Mana functions. Variables
can be numeric or character strings. If the shell does not understand
the syntax of the line as a math expression, it is assumed to be a
string.
Some of the programming functions are for loops and if (if else) statements. There are no delimiting characters; ends of program blocks are defined by the word 'end'. Syntax is rather simplistic at the moment. For example:
for i 1 10 0.1 echo $i end macro test echo "this is a macro" echo "number of arguments $0" echo "first argument $1" if ($1 = 10) echo first argument is 10 end end
Some of the other useful programming features are the ability to run files as scripts ( input (filename)) and the option of performing unix system calls ( exec (command)).