You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to github so I do not know another way to contact you.
I like this shell script for test driving forth, without installing an compiled program.
Thanks for this software.
Here is a code that in my copy of the 0.59a bashforth version function well for save-system and load-system:
save_array_print() {
local i
local inext
local -n a=$1
inext=0
printf "a0\n"
for i in "${!a[@]}"; do
if [ "$inext" != "$i" ]; then
printf 'ao %s\n' "$i"
fi
printf 'a %s\n' "${a[i]}"
let "inext=++i"
done
}
# -----------------------------------------------------------------------------
# ------------------------------- save-system ---------------------------------
# -----------------------------------------------------------------------------
# ( a c -- )
code saveas saveas
saveas() {
local i
local inext
local len
pack
(
printf "version %s\n" "$version"
printf "wc %s\n" "$wc"
printf "dp %s\n" "$dp"
save_array_print m
save_array_print h
save_array_print hf
save_array_print x
) > $tos
tos=${s[sp--]}
}
# ( -- ) write image of system to file, file name taken from input stream
revealheader "save-system"
colon savesystem $bl $stream $saveas
# -----------------------------------------------------------------------------
# ------------------------------- load-system ---------------------------------
# -----------------------------------------------------------------------------
# ( a c -- )
code loadfrom loadfrom
function loadfrom {
local load_version
local cmd
local prg
local a
local ai
local linenr
pack
m=()
h=()
hf=()
x=()
ai=0
a=0
fname=$tos
tos=${s[sp--]}
linenr=0
while read -r line
do
prg=($line)
cmd=${prg[0]}
p1=${prg[1]}
p2=${prg[2]}
case $cmd in
version)
load_version=$p1
if [ "$load_version" != "$version" ]; then
echo "Not same Version : $load_version"
fi
;;
wc)
wc=$p1
;;
dp)
dp=$p1
;;
a0)
ai=0
let "a=++a"
;;
ao)
ai=$p1
;;
a)
case $a in
1)
m[ai++]=$p1
;;
2)
h[ai++]=$p1
;;
3)
hf[ai++]=$p1
;;
4)
x[ai++]=$p1
;;
esac
;;
hlt)
ai=0
break;
;;
esac
let "linenr=++linenr"
done < $fname
}
The text was updated successfully, but these errors were encountered:
This looks useful and functional. I have added your version to bashforth. Thank you very much for your contribution.
One of the slight modifications I did to your code was to allow execution of save-system and restore without giving a file name. In this case will saving/restoring happen with a preset file name. This allows
easy restarting and restoring bashforth with a command like "bashforth restore" to the version previously save with "save-system". Currently, this file doesn't default to another location than current directory - it may be practical to let it default to, for example, sourcepath directory.
I'll leave this issue open until you reported the addition functional in spite of the modifications which I've applied.
I am new to github so I do not know another way to contact you.
I like this shell script for test driving forth, without installing an compiled program.
Thanks for this software.
Here is a code that in my copy of the 0.59a bashforth version function well for save-system and load-system:
The text was updated successfully, but these errors were encountered: