Dark Bit Factory & Gravity
PROGRAMMING => Other languages => Yabasic => Topic started by: bikemadness on February 14, 2013
-
When I started learning Yabasic, I also looked for samples that would be useful.
Making screensavers is fun, but I wanted practical as well.
I realised I had to write them myself.
Like this one, for example.
I needed a list of numbers worked from a formula and sitting down with calculator
and pencil was out of the question. I took a picture of the running program and
printed from that.
The window could be altered to the same ratio as an A4 sheet of paper.
open window 640,512 rem .>
pi=3.14159
repeat
setdispbuf vm
vm=1-vm
setdrawbuf vm
clear window
setrgb 1,256,256,256
fill rectangle 0,0 to 640,512
setrgb 1,256,256,256
f=90.2
for a=1 to 40
f=f+(f/9.038)
y=0
for R=2 to 16 step R
y=y+1
L=R/(1.414*pi*f) rem formula
C=1/(2.818*pi*f*R) rem formula
if len(str$(int(f)))=3 then
i=30
else
i=20
endif
D=C*1000000
setrgb 1,0,0,0
text i,a*12+25,str$(int(f))
if len(str$(int(L*100000)))=4 ii=-10
if len(str$(int(L*100000)))=3 ii=0
if len(str$(int(L*100000)))=2 ii=10
if len(str$(int(L*100000)))=1 ii=20
text y*140-50+ii,a*12+25,str$(int(L*100000))
if D>100 text y*140+20,a*12+25,str$(C*1000000,"###")
if D<100 and D>10 text y*140+30,a*12+25,str$(C*1000000,"##")
if D<10 and D>1 text y*140+20,a*12+25,str$(C*1000000,"#.#")
text 10,18,"freq."
text y*140-40,18,"I"
text y*140+30,18,"C"
text y*140-30,10,str$(R)+" ohm"
setrgb 1,150,150,150
line 10,a*12+17 to 630,a*12+17
line y*140-70,30 to y*140-70,510
line y*140,30 to y*140,510
next R
next a
until (1=0)
By the way, these are xover values for speaker cabinet systems.
This has been my main interest in using Yabasic.