This little program I originally wrote for LB some time ago is really intended for students. I have checked again the accuracy of the tables, which seem to be still OK. First of all it should be pointed out LB and JB like Qbasic calculates all trigonometric functions like SIN and TAN etc in Radians, so you will notice the factor RAD is defined in the early part of the program for converting these functions in Radians into Degrees. Likewise LOG calculates to the base ‘e’ usually called ‘ natural logarithms ‘ so we multiply by 0.43429 in [fn] to convert to Common Logarithms as published in normal LOG. Tables.
Also I must own up to the way Prime numbers in [prms] are calculated as being the work of someone else whose name I cannot remember. If you run the program TRIGRAPH from my site below with LB, you will probably find the tables are displayed much smoother than JB, because of the use of an invisible texteditor, where the table is initially created, then copied over to the text window all in one operation. This is achieved using an additional function !select of LB not available with JB.
The only other unusual code perhaps worth mentioning is at the very start for placing the window around the centre of the screen. I am sure you can improve on this program to suit your own particular requirements etc, so why not let us a l know of your amendments in the News Letter section of http://justbasic.conforums.com/index.cgi
nomainwin
ux = 1 : uy = 1 : mx = 6
if DisplayWidth > 1000 then ux = 120 : uy = 90 : mx = 8
[opts]
bx = 0
UpperLeftX = ux : UpperLeftY = uy
WindowWidth = 800 : WindowHeight = 580
menu #t, "&FUNCTIONS","&Arctangent",[art],"Cosine",[cos],_
"Cotangent",[cot],"&Sine",[sin],"Tangent",[tan],"Secant",[sec],_
"&Cosecant",[cnt],"Degrees to Radians",[deg],"Natural Logarithm",[log],_
"Common Logarithm",[clg],"Exponential",[exp],"Prime Numbers",[prm]
menu #t, "&QUIT","&Quit",[quit]
tl$ = "PRIME NUMBER & GRAPH OF TRIGOMETRIC FUNCTIONS."
open tl$ for graphics_nsb as #t
#t "trapclose [quit]; font arial 20 bold; color blue; place 50 100; down"
#t "\TRIGOMETRICAL FUNCTIONS AND PRIME NUMBERS"
#t "\\";space$(12);"SELECT FROM THE FUNCTIONS MENU."
#t "font arial 18 bold; place 170 220; color darkgreen"
#t "\Once the table is displayed use the"
#t "\menu to select a Graph or new Table."
RAD = 3.141592654 / 180 'converts LB trig. functions in radians to degrees
dim flags(1001)
prm = 0 : playwave "any"
#t "flush"
wint = 1 : wait
[art] f = 1 : trig$ = "Arctangent " : goto [box2]
[cos] f = 2 : trig$ = "Cosine " : goto [box2]
[cot] f = 3 : trig$ = "Cotangent " : goto [box2]
[sin] f = 4 : trig$ = "Sine " : goto [box2]
[tan] f = 5 : trig$ = "Tangent " : goto [box2]
[sec] f = 6 : trig$ = "Secant " : goto [box2]
[cnt] f = 7 : trig$ = "Cosecant " : goto [box2]
[log] f = 8 : trig$ = "Natural Logarithm " : goto [box2]
[clg] f = 9 : trig$ = "Common Logarithm " : goto [box2]
[exp] f = 10 : trig$ = "Exponential " : goto [box2]
[deg] f = 11 : trig$ = "Degrees to Radians" : goto [box2]
[prm] f = 12 : trig$ = "Prime Numbers "
[box2]
if f > 10 then
tx1$ = ""
tx2$ = "First Number"
tx3$ = "Last Number"
goto [miss]
end if
tx1$ = "Maximum Calculation Plots of:-"
tx2$ = " from 10 to 360."
tx3$ = " from 10 to 500"
[miss]
UpperLeftX = 250+ux: UpperLeftY = 300+uy
WindowWidth = 260 : WindowHeight = 160
statictext #box, "Enter", 100, 10, 50, 20
statictext #box, tx1$, 30, 30, 230, 20
statictext #box, tx2$, 20, 48, 100, 20
statictext #box, tx3$, 150, 48, 100, 20
textbox #box.tbox1, 40, 70, 40, 24
textbox #box.tbox2, 180, 70, 40, 24
button #box.default, "Accept", [pass], UL, 100, 70, 60, 25
open "Values and Plots" for dialog as #box
print #box, "trapclose [quit]"
print #box, "font arial 10 bold"
print #box.tbox1, 10
print #box.tbox2, 100
[pick]
playwave "anything"
bx=1 : pc = 0
wait
[pass]
print #box.tbox1, "!contents? A$" : M = val(A$)
print #box.tbox2, "!contents? B$" : P = val(B$)
if f = 12 then [primes]
if M < 10 or M > P or P < M or P > 500 then
not$ = "INVALID - limits 10/360 & 500"
[no] notice not$
goto [pick]
end if
if f = 10 and M > 88 then M = 88 ' max. Exponentials
[bfin]
first = 1
close #box : bx = 0 : close #t : wint = 0 : goto [table]
[primes]
if M < 0 or M > P or P < M or P > 1000 then
not$ = "INVALID - limits 0 & 1000"
goto [no]
else
goto [bfin]
end if
[table]
menu #v, "&CONTINUE","&Graph",[graph],"New Table",[new],|,"&Quit",[quitv]
tl$ = trig$+" values from "+str$(first)+" to "+str$(P)
if f < 8 then tl$=tl$+" - IN DEGREES ***"
open tl$ for text_fs as #v
#v "!trapclose [quitv]"
#v "!font fixedsys"
if f = 11 then [rads]
if f = 12 then [prms]
goto [trigs]
[new] close #v : goto [opts]
[trigs]
S = P/500 : lin = 1
for FX = M to P STEP S
if f < 8 then N = FX * RAD else N = FX
gosub [fn]
if Z < 1 then YC = 175: YS = 150
#v using("####.#", FX);
if Z > 99 then #v USING("########", INT(Z));
if Z < 100 then #v USING("###.####", Z);
lin = lin + 1
if lin > mx then #v " " : lin = 1
next FX
#v "!origin 1 1"; ' move scroll bars back
wait
[graph] close #v
UpperLeftX = ux : UpperLeftY = uy
WindowWidth = 800 : WindowHeight = 580
button #t " NEW ", [more], LL 360, 1
open "Graph" for graphics_nsb as #t
if f = 11 or f = 12 then goto [opts]
#t "trapclose [quit]; discard; cls; color red; size 2; down"
#t "line 0 250 780 250; color black"
S = M / P: XS = 780 / P : PX = 0
YMAX = 200 : IF f = 10 THEN YMAX = 1
for N = .1 to M STEP S
gosub [fn]
PX = PX + XS : PY = Z * YMAX + 250
if PY < 1000 then #t "set ";PX;" ";PY
#t "set XP YP"
next N
wint = 1 : wait
[more]
close #t : goto [opts]
[rads]
lin = 1
for N = first to P
#v N;
#v using("###.####", N*RAD);
lin = lin + 1
if lin > mx then #v " " : lin = 1
NEXT N
wait
[prms]
redim flags(1001)
sieve = 0
for i = M to P
if flags(i) = 0 then
prime = i + i + 3
k = i + prime
while k <= P
flags(k) = 1
k = k + prime
wend
sieve = sieve + 1
if sieve/20 = int(sieve/20) then #v " "
#v using("#####", prime);
if prime > P then flags(i) = 0 : i = P +2
end if
next i
#v " " : #v " TOTAL FOUND ";sieve
wait
[fn]
select case f
case 1 : Z = ATN(N)
case 2 : Z = COS(N)
case 3 : Z = 1/TAN(N)
case 4 : Z = SIN(N)
case 5 : Z = TAN(N)
case 6 : Z = 1/COS(N)
case 7 : Z = 1/SIN(N)
case 8 : Z = LOG(N)
case 9 : Z = LOG(N)*0.43429
case 10 : Z = EXP(N)
end select
return
[quitv] close #v
[quit]
if wint = 1 then close #t
if bx = 1 then close #box
end