add output file for last top of stack
This commit is contained in:
parent
5812333583
commit
532fb8c3ec
|
@ -13,6 +13,8 @@ This wrapper renders `dc` more usable as a command line calculator by:
|
||||||
- defining commonly used macros for more complex operations
|
- defining commonly used macros for more complex operations
|
||||||
- saving precision, top of stack, and registers 0 to 9 ("memories")
|
- saving precision, top of stack, and registers 0 to 9 ("memories")
|
||||||
from one invocation to the next in the status file `$HOME/.wdcrc`
|
from one invocation to the next in the status file `$HOME/.wdcrc`
|
||||||
|
- saving last top of stack value in `$HOME/wdc` for further direct use
|
||||||
|
(change file name in the source, if desired)
|
||||||
|
|
||||||
# PREREQUISITES
|
# PREREQUISITES
|
||||||
|
|
||||||
|
@ -160,8 +162,10 @@ only at the very end. Otherwise, e.g the `rem` command would first have its
|
||||||
|
|
||||||
# FILES
|
# FILES
|
||||||
|
|
||||||
The status between invocations is stored in the file `$HOME/.wdcrc` as a
|
- The status between invocations is stored in the file `$HOME/.wdcrc` as a list of `dc` commands.
|
||||||
list of `dc` commands.
|
- The last top of stack value is stored in `$HOME/wdc`.
|
||||||
|
|
||||||
|
_These file names can be easily changed at the beginning of the script._
|
||||||
|
|
||||||
# BUGS
|
# BUGS
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# wrapper for dc
|
# wrapper for dc
|
||||||
info="wrapper for dc // 2016-11-22 Y.Bonetti // see https://gitlab.com/yargo/wrapdc"
|
info="wrapper for dc // 2017-03-10 Y.Bonetti // see https://gitlab.com/yargo/wrapdc"
|
||||||
# global status file
|
# global status file
|
||||||
statf=$HOME/.wdcrc
|
statf=$HOME/.wdcrc
|
||||||
|
# output file (last stack top)
|
||||||
|
outf=$HOME/wdc
|
||||||
# clear state: precision 2, clear stack and reg.0..9
|
# clear state: precision 2, clear stack and reg.0..9
|
||||||
clstat='2k 0 0 0 0 0 0s00s10s20s30s40s50s60s70s80s9'
|
clstat='2k 0 0 0 0 0 0s00s10s20s30s40s50s60s70s80s9'
|
||||||
if test ! -r $statf
|
if test ! -r $statf
|
||||||
|
@ -112,6 +114,8 @@ LEl:x[
|
||||||
# divide stack top by 10^A and print, print A
|
# divide stack top by 10^A and print, print A
|
||||||
lA10lAZLAX-1-sAlA^/n[E]nLAp
|
lA10lAZLAX-1-sAlA^/n[E]nLAp
|
||||||
ENDOFDCINPUT
|
ENDOFDCINPUT
|
||||||
|
# save stack top in output file for further direct processing
|
||||||
|
tail -n 1 $statf | sed -e 's/ *#.*//' >$outf
|
||||||
# print stack top
|
# print stack top
|
||||||
tail -n 1 $statf
|
tail -n 1 $statf
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue