MPE/iX Shell and Utilities Reference Manual, Vol 1

bc(1) MPE/iX Shell and Utilities bc(1)
quit
terminates bc. In other implementations of bc, the interpreter exits as soon as it reads
this token. This version of bc treats quit as a real statement, so you can use it in loops,
functions, and so on.
sh ...
lets you send a line to the
MPE/iX Shell for execution, as in
sh more <foo
This command passes everything from the first non-blank character until the end of the
line to the shell for execution.
void expression
void throws away or voids the result of the evaluation of expression instead of display-
ing it. This is useful when using ++ and -- operators, or when you want to use a func-
tion but don’t want to use the return value for anything. For example,
void foo++
increments foo but does not display the result. The void statement is unique to this
version of bc.
Several other types of statements are only relevant in function definitions. These are
described in the next section.
Functions
A function is a subprogram to calculate a result based on argument values. For example, the
following function converts a temperature given in Fahrenheit into the equivalent temperature
in Celsius.
define f_to_c(f) {
return ((f-32)*5/9)
}
This defines a function named f_to_c() that takes a single argument called f. The body of
the function is enclosed in brace brackets. The opening brace must be on the same line as the
define keyword. The function body consists of a sequence of statements to calculate the
result of the function. An expression of the form
return (expression)
returns the value of expression as the result of the function. The parentheses around the
expression are optional.
1-56 Commands and Utilities