#!/bin/ksh ## ## SCRIPT: calcline ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ############################################################################ ## PURPOSE: Calculates formulas entered by user ... line by line. ## ############################################################################ ## CALLED BY: feamain -> feautils.menu -> office_utils.menu script ## and 'officetools' toolchest/command. ############################################################################ ## MAINTENANCE HISTORY: ## Written by: B. Montandon C61 8Jun1995 ## Updated by: B. Montandon O06 27May1999 Chgd 'bc' to 'bc -l' (add lib funcs) ## Updated by: B. Montandon T17 2Jan2001 Added 'officetools' where-used note ## above, and added a few examples. ## Updated by: B. Montandon T17 5Jan2001 Added '%' (remainder) examples. ############################################################################ if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi . $FEDIR/scripts/clearnns echo "\ ............................................................................. ${HIbold}calcAline: Calculate expressions entered ... line by line. EXAMPLES:${HIreset} (30 * 3.1 + 25.7) / 83.2 ${HIdim}OR${HIreset} (30*3.1+25.7)/83.2 4^3 sqrt(83) c(3.14159) 4.0 * a(1) s(4.0 * a(1)) 3.0 * e(-2.5 * 1.1) l(e(1)) scale=0;4%3 scale = 0 ; 3 % 4 ${HIdim} Command used: echo 'scale = 10; ' | bc -l ${HIbold} Categories of 'bc' OPERATORS: ------------- ---------------------------------------------- Arithmetic: + - * / ^ % (^ is power ; % is remainder) Functions: sqrt(x) square root s(x) sine c(x) cosine e(x) exponential l(x) log a(x) arctangent Comparison: == <= >= != < > Assignment: = =+ =- =* =/ =% =^ Concatenate: ++ -- (prefix and postfix; apply to names) ${HIbold} NOTE: You may mouse-paste input or results from previous lines at the current prompt. Try pasting the examples above (or parts of them). ${HIreset} ............................................................................" # *** Press Enter to Continue." # read NNS_JUNK xpress="something" while test ! "${xpress}" = "" do echo " ${HIbold}Enter an expression. ==>${HIreset} \c" read xpress if test "${xpress}" = "" then continue # exit fi ## FOR TESTING: # set -x echo "scale = 10; $xpress" | bc -l ## FOR TESTING: # set - done