Looks may be decieving
Wanted a simple business program that I could run on a minimal or embedded machine that emulated the old Fish Market dbase example from years ago. Probably could of used Harbour software, but was not happy with it. Dbase is no longer around, so I can not run it on Linux. Could always use an sql program to control the database. Decided to use bash as the front end, Next was to see how hard it would be to emulate the the screens generated in Dbase.
Commented in an earlier article that it is good to know several languages. Here even knowing just a minimal amount about the dbase language allowed there to be a port of the code. Two examples of the code where one was done with dbase and the other was done in bash. Fortunately I was able to convert the main menu for starters. Here are the two screen shots accomplishing the same goal of a main menu:
Actually it was not that hard to port the code from dbase to bash so far. In fact the code for both looks a lot the same.
Dbase:
mainmenu,prg
**************************************
* *
* Main *
* Eddie's fish market *
* main menu *
* main.prg *
* *
**************************************
set catalog to fredfish
set catalog on
set delimiter off
set echo off
set exact off
set talk off
set bell off
set confirm off
set intensity on
set status off
set deleted on
store .f. to exit
store ' ' to option
clear
do while .not. exit
@ 1,20 say "Eddie's Friendly Fish Market"
@ 3,20 say ' Main Menu'
@ 7,20 say 'Enter selection: ' ;
get option
@ 10,22 say '1 - Customer system'
@ 11,22 say '2 - Employee system'
@ 12,22 say '3 - Order system'
@ 13,22 say '4 - Inventory system'
@ 15,22 say 'X - Exit system'
@ 21,12 say 'Copyright (c) 1994 by tabby little books'
@ 22,12 say 'Copyright (c) 1994 by kermit the phrog'
read
do case
case option = '1'
do customer
case option = '2'
do employee
case option = '3'
do order
case option = '4'
do inventory
case upper(option) = 'X'
return
otherwise
? chr(7)
@ 5,18 say '*** invalid entry - retray again ***'
endcase
store ' ' to option
enddo
mainmenu.sh
#!/bin/bash
#**************************************
#* *
#* Main *
#* Eddie's fish market *
#* main menu *
#* main.sh *
#* *
#**************************************
#===============================
# Functions
#--------------------------------
# pc = position cursor
function pc () {
tput cup $1 $2
}
#===============================
# daffinitons
#-------------------------------
# set catalog to fredfish
# set catalog on
# set delimiter off
# set echo off
# set exact off
# set talk off
# set bell off
# set confirm off
# set intensity on
# set status off
# set deleted on
# true="-1"
exit="f"
option=" "
#=====================================
# main menu
#-------------------------------------
clear
while true; do
pc 1 20 ; echo "Eddie's Friendly Fish Market"
pc 3 20 ; echo ' Main Menu'
pc 7 20 ; echo 'Enter selection: '
pc 10 22 ; echo '1 - Customer system'
pc 11 22 ; echo '2 - Employee system'
pc 12 22 ; echo '3 - Order system'
pc 13 22 ; echo '4 - Inventory system'
pc 15 22 ; echo 'X - Exit system'
pc 21 12 ; echo 'Copyright (c) 2014 by computothought'
pc 22 12 ; echo 'Copyright (c) 2014 by computoman'
pc 7 37
read -s -n1 option
case $option in
[1] )
./customer.sh
;;
[2] )
./employee.sh
;;
[3] )
./order.sh
;;
[4] )
./inventory.sh
;;
[xX] )
pc 25 1
break
;;
*)
# printf '\a' ;
# beep
pc 5 18; echo '*** invalid entry - retry again ***'
;;
esac
option=" "
done
#-----------------------------------------------
# end of code
#================================================
This is a good reason why people should have the source code to software so they can adapt it to newer systems. Lot of work to do, but there always is. Let you know how it goes.
Commented in an earlier article that it is good to know several languages. Here even knowing just a minimal amount about the dbase language allowed there to be a port of the code. Two examples of the code where one was done with dbase and the other was done in bash. Fortunately I was able to convert the main menu for starters. Here are the two screen shots accomplishing the same goal of a main menu:
Actually it was not that hard to port the code from dbase to bash so far. In fact the code for both looks a lot the same.
Dbase:
mainmenu,prg
**************************************
* *
* Main *
* Eddie's fish market *
* main menu *
* main.prg *
* *
**************************************
set catalog to fredfish
set catalog on
set delimiter off
set echo off
set exact off
set talk off
set bell off
set confirm off
set intensity on
set status off
set deleted on
store .f. to exit
store ' ' to option
clear
do while .not. exit
@ 1,20 say "Eddie's Friendly Fish Market"
@ 3,20 say ' Main Menu'
@ 7,20 say 'Enter selection: ' ;
get option
@ 10,22 say '1 - Customer system'
@ 11,22 say '2 - Employee system'
@ 12,22 say '3 - Order system'
@ 13,22 say '4 - Inventory system'
@ 15,22 say 'X - Exit system'
@ 21,12 say 'Copyright (c) 1994 by tabby little books'
@ 22,12 say 'Copyright (c) 1994 by kermit the phrog'
read
do case
case option = '1'
do customer
case option = '2'
do employee
case option = '3'
do order
case option = '4'
do inventory
case upper(option) = 'X'
return
otherwise
? chr(7)
@ 5,18 say '*** invalid entry - retray again ***'
endcase
store ' ' to option
enddo
mainmenu.sh
#!/bin/bash
#**************************************
#* *
#* Main *
#* Eddie's fish market *
#* main menu *
#* main.sh *
#* *
#**************************************
#===============================
# Functions
#--------------------------------
# pc = position cursor
function pc () {
tput cup $1 $2
}
#===============================
# daffinitons
#-------------------------------
# set catalog to fredfish
# set catalog on
# set delimiter off
# set echo off
# set exact off
# set talk off
# set bell off
# set confirm off
# set intensity on
# set status off
# set deleted on
# true="-1"
exit="f"
option=" "
#=====================================
# main menu
#-------------------------------------
clear
while true; do
pc 1 20 ; echo "Eddie's Friendly Fish Market"
pc 3 20 ; echo ' Main Menu'
pc 7 20 ; echo 'Enter selection: '
pc 10 22 ; echo '1 - Customer system'
pc 11 22 ; echo '2 - Employee system'
pc 12 22 ; echo '3 - Order system'
pc 13 22 ; echo '4 - Inventory system'
pc 15 22 ; echo 'X - Exit system'
pc 21 12 ; echo 'Copyright (c) 2014 by computothought'
pc 22 12 ; echo 'Copyright (c) 2014 by computoman'
pc 7 37
read -s -n1 option
case $option in
[1] )
./customer.sh
;;
[2] )
./employee.sh
;;
[3] )
./order.sh
;;
[4] )
./inventory.sh
;;
[xX] )
pc 25 1
break
;;
*)
# printf '\a' ;
# beep
pc 5 18; echo '*** invalid entry - retry again ***'
;;
esac
option=" "
done
#-----------------------------------------------
# end of code
#================================================
This is a good reason why people should have the source code to software so they can adapt it to newer systems. Lot of work to do, but there always is. Let you know how it goes.
Comments
Post a Comment