#! /command/awk -f
## /source/script/awk/add

## an adding machine

## call as     awk -f /source/script/awk/total

## not real feature-ful. More comment than code. Think "module".
# Nicolo Di Medici woulda been tickled to death with it though.



# for each line of input

BEGIN { 
printf "\n\nSimple adding machine\n\n"
print "input a number, hit enter, see subtotal."
print "prepend a - to negative numbers, e.g.   -567<enter>"
print "hit ctrl&d to exit."
print "Leaves a file \"tape\" in /temp/tape."
print "can be scripted."
print ""
}

# per input line
{ 
ACCUMULATOR = ACCUMULATOR + $1
printf "%f\t\t\t%f\n", $1,  ACCUMULATOR  > "/.tm/tape"  
printf "       %f\n", ACCUMULATOR 
}
