# iConvert.bas
draw -1
form fld 2,30,30,12, "",1
form fld 50,30,30,12, "",1
form fld 2,57,40,12, "",1
form cbx 80,80,w,h,"",1
form cbx 80,90,w,h,"",1
form cbx 112,80,w,h,"",1
form cbx 112,90,w,h,"",1
form cbx 80,116,w,h,"",1
form cbx 80,126,w,h,"",1
form cbx 112,116,w,h,"",1
form cbx 112,126,w,h,"",1
form btn 117,147,40,12, "Enter",1
draw "Select Input",2,80,1
draw "to",35,32,1
draw "4-20 mA",124,82
draw "0-5 volts",124,92
draw "Lbs",92,82
draw "Psi",92,92
draw "Select Output",2,116,1
draw "4-20 mA",124,118
draw "0-5 volts",124,128
draw "Lbs",92,118
draw "Psi",92,128
draw "Enter Instrument Range",2,18,1
draw "Enter Data",2,45,1
#for i=0 to 12 : s$(i)="0": next i
top:
while
x = asc(input$(1))
l=val(s$(0))
h=val(s$(1))
y=val(s$(2))
if l<>0 then h=h-l
if l<>0 then y=y-l
if l<>0 then l=l-l
if val(s$(5)) then y=val(s$(2))
if val(s$(6)) then y=val(s$(2))
r$="Result: "
lb$=" lbs"
ps$=" Psi"
ma$=" mA"
vs$=" volts"
i$="Enter Input Data."
n$="Enter Instrument Range."
o$="Data not within range."
if s$(0)="" then ? n$ :goto top
if s$(1)="" then ? n$ :goto top
if s$(2)="" then ? i$ :goto top
#if val(s$(2))val(s$(1)) then ?o$: goto top
e=val(s$(3))+val(s$(4))+val(s$(5))+val(s$(6))
if e<1 then ? "Select Input." : goto top
if e>1 then ? "Select 1 Input." : goto top
f=val(s$(7))+val(s$(8))+val(s$(9))+val(s$(10))
if f<1 then ? "Select Output." :goto top
if f>1 then ? "Choose only1 Output." :goto top
if val(s$(3))+val(s$(9))=2 then goto lb2ma
if val(s$(3))+val(s$(10))=2 then goto lb2vo
if val(s$(4))+val(s$(9))=2 then goto lb2ma
if val(s$(4))+val(s$(10))=2 then goto lb2vo
if val(s$(5))+val(s$(7))=2 then goto ma2lb
if val(s$(5))+val(s$(8))=2 then goto ma2lb
if val(s$(6))+val(s$(7))=2 then goto vo2lb
if val(s$(6))+val(s$(8))=2 then goto vo2lb
wend
lb2ma:
if yh then print m$:wend
m$=(16/h)*y+4
print r$+m$+ma$
wend
lb2vo:
if yh then print m$:wend
m$=(5/h)*y
print r$+m$+vs$
wend
ma2lb:
if val(s$(2))<4 then ? o$ :wend
if val(s$(2))>20 then ? o$ :wend
if val(s$(7))=1 then z$=lb$
if val(s$(8))=1 then z$=ps$
if val(s$(0))<0 then w=val(s$(0))*-1
w=s$(0)
p$=(h/16)*(y-4)+w
print r$+p$+z$
wend
vo2lb:
if val(s$(2))<0 then ? o$ :wend
if val(s$(2))>5 then ? o$ :wend
if val(s$(7))=1 then z$=lb$
if val(s$(8))=1 then z$=ps$
if val(s$(0))<0 then w=val(s$(0))*-1
w=s$(0)
b$=(h/5)*y+w
print r$+b$+z$
wend
end