!*************************** AMUS Program Label ******************************
! Filename: QCALC.RUN Date: 10/9/91
! Category: UTIL Hash Code: 124-364-305-624 Version: 1.0(103)
! Initials: GR/AM Name: James A. Jarboe IV
! Company: Educational Video Network, Inc. Telephone #: 4092955767
! Related Files: D/BASIC OR D/RUN
! Min. Op. Sys.: 1.3 Expertise Level: BEG
! Special: Get STDMAC.MAC, and STDMAC.BSI to compil under d/BASIC
! Description: A quick d/BASIC calculater and/or d/BASIC expression evaluator.
! Can evaluate d/BASIC string and/or math expressions.
!
!*****************************************************************************
!*! Updated on 08-Oct-91 at 12:06 AM by James A. Jarboe I V; edit time: 3:08:32
!****************************************************************************
! *
! QCALC.BAS - An interactive d/BASIC calculator and expression handler. *
! *
!****************************************************************************
!
! This program accepts d/BASIC expressions and/or functions and determines
! the results.
! - OR -
! This is what happens when a programmer wants a simple way to add 1+2
! and gets carried away with the idea.
!
! This program was designed,implemented
!
! James A. Jarboe IV GR/AM
! Educational Video Network, Inc
! 1401 19th Street
! Huntsville, TX 77340
! 1-409-295-5767
!
! Edit History:
!
PROGRAM QCALC, 1.0(103)
!
! [103] 07-Oct-91 Added check for .FNK file.
! [102] 03-Oct-91 Added F1,F2,F3 help to screen.
! [101] 02-Oct-91 Added Base display and selection.
! [100] 27-Sep-91 Written - James A. Jarboe IV
!
! Additional files:
! STDMAC.BSI - Include file with variables that STDMAC.MAC uses.
! STDMAC.MAC - Compiled Macro file used with this program.
! QCALC.HLP - Online help file for QCALC.RUN
!
! - NOTES -
! Must use with d/RUN version 1.2 or greater.
! STDMAC.BSI should be located in BAS:
! STDMAC.MSC is the macro source and can be located where you want.
! QCALC.HLP should be located in HLP:
!
!
!
++include STDMAC
!
map1 a$,s,100 ! EVAL string.
map1 b$,s,100 ! SEVAL string.
map1 x$,s,132
map1 fm,s,30 ! Form string.
map1 bin'cvt, b, 4 ! Binary conversion variable.
map1 bin'byt,@bin'cvt ! Word conversion variable.
map2 by'byte(4), b, 1
map1 bin'wrd,@bin'cvt ! Byte conversion variable.
map2 by'word(2), b, 2
map1 save'a$(max's), s, 100 ! Saved input strings.
map1 save'lvl, f, 6 ! Current retrieve level.
float a, e'c ! Misc floating point variables.
! Define Prompt row and column.
!
def pm'r = 8
def pm'c = 14
!
!! Field input Description.
!
input.field calc
start at end
located at pm'r,pm'c
maximum size 55
exit using ESCAPE, ^C, ^K, ^J, HELP, F7, TAB, F13, F1, F2, F3
end field
!
on error goto endit
find.funkey
!! Set up Screen.
!
x$ = .date using "#ZZZZZ"
x$ = .day+", "+.month+" "+str(val(x$[3;2]))+", 19"+x$[5;2]
x$ = .osname+" "+.dosversion+" "+x$
init.term "By James A. Jarboe IV",x$,"Current User: "+.username
call SET'UP'SCREEN
a$ = ""
!!!!!!!!!!!!!!
!! MAIN LOOP!!
!!!!!!!!!!!!!!
! Accept user input until we are finished.
!
do accept.field calc into a$, e'c until e'c = 'ESCAPE' or e'c = 3 or e'c = 'F13'
? tab(-1,29);
if e'c = 11 call UP'ONE : again
if e'c = 10 call DN'ONE : again
if e'c = 'HELP' call HELP : again
if e'c = 'TAB' call HELP : again
if e'c = 'F7' call PICK'OPTION : again
when e'c = 'F1' or e'c = 'F2' or e'c = 'F3'
switch on e'c
case 'F1' : call reset'norm : endcase
case 'F2' : call reset'word : endcase
case 'F3' : call reset'byte : endcase
endswitch
call DISPLAY'OPTIONS
call show'base
again
wend
! If no input get some.
!
if a$ = "" again
a = 0
call show'equate
! If command is preceeded by a "$" then use SEVAL otherwise use EVAL.
!
when display'numb = .false
if a$[1,1] <> "$" then a$="$"+a$
wend
when a$[1,1] = "$"
b$=seval(a$[2,-1])
else
a=eval(a$)
wend
!
!! Clear Screen of Base Prompts.
!
clear'base:
for x = 5 to 8
? tab(pm'r+x,bx'c+2);space$(50);
next x
return
! On up arrow bring back previous input line.
!
UP'ONE:
x = save'lvl
x+=1
if x > max's then x = max's : call BELL
if save'a$(x) = "" x-=1 : call BELL
if x<1 x = 1
a$ = save'a$(x)
save'lvl = x
call show'input
return
! On down arrow bring back last input line.
!
DN'ONE:
x = save'lvl
x-=1
if x < 1 x = 1 : call BELL
a$ = save'a$(x)
save'lvl = x
call show'input
return
!
!! Ring the bell
!
BELL:
? chr$(7);
return
!
!! Get some help
!
HELP:
? tab(-1,0);
rundos "HELP QCALC"
? TAB(-1,0);
call SET'UP'SCREEN
call show'result
return
!
!! Display the Option window.
!
DISPLAY'OPTIONS:
dual.print tab(bx'r+bx'l-2,bx'c+2);
when display'base = .true
dual.print "Display Base as _";
if display'norm = .true then dual.print "_Normal "
if display'word = .true then dual.print "_Words "
if display'byte = .true then dual.print "_Bytes "
else
dual.print "_No_ Base Display "
call clear'base
wend
x = int((bx'w/2)+bx'c+3)
dual.print tab(bx'r+bx'l-2,x);"Input Mode: _";
when display'numb = .true
dual.print "_NUMERIC_ ";
else
dual.print "_STRING_ ";
wend
return
!
!! Pick an option from the list.
!
PICK'OPTION:
wipebox bx'r+1, bx'c+9, 10, 40
pick'me(1) = pick'1
pick'me(2) = pick'2
when display'base = .true
pick'me(1)= pick'me(1)+"OFF"
else
pick'me(1)= pick'me(1)+"ON"
wend
when display'numb = .true
pick'me(2) = pick'me(2)+"STRINGS "
else
pick'me(2) = pick'me(2)+"NUMERICS"
wend
reset uplowcase
pick.list into pick'select
text array pick'me(1)
located at bx'r+2, bx'c+10
depth 5
title "Select Option or ESCAPE to EXIT"
end picklist
set uplowcase