-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtemperature.bas
More file actions
108 lines (102 loc) · 2.37 KB
/
Copy pathtemperature.bas
File metadata and controls
108 lines (102 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
rem Title: temperature
rem Description:
rem Category: Applications
rem Copyright: Andrei Besleaga
rem Email: andbes@mailsurf.com
rem Created: 05 February 2003
rem Version: 1.0
rem Sbver:
'#!/usr/bin/sbasic -g
'' SmallBASIC Temperature Converter
'' (c)2003 - Andrei Besleaga
''
'' to demonstrate menus selection with pen/mouse
10 cls
print cat(1);"*** Temperature Converter ***";cat(0)
print " (c)2003 - Andrei Besleaga"
print
input "Temperature: ";temp
cls
print "convert from: ";temp;" degrees"
at 20,30
print "Celsius"
at 20,60
print "Fahrenheit"
at 20,90
print "Kelvin"
at 20,120
print "Rankine"
print
rect 10,25,100,50
rect 10,55,100,80
rect 10,85,100,110
rect 10,115,100,140
tfrom=getmenu
print tfrom;" to:"
delay 500
tto=getmenu
cls
print temp;" deg ";tfrom;" = ";tempout(temp,tfrom,tto);" deg ";tto
beep
print
print "calculate another ?"
print " yes no"
rect 10,45,55,65
rect 60,45,105,65
pen on
repeat
if pen(0)
x=pen(4):y=pen(5)
if (y>45 and y<65) and ((x>10 and x<55) or (x>60 and x<105)) then
if x<55 then
goto 10
else
exit loop
endif
endif
endif
until
pen off
func tempout(temp,tfrom,tto)
if tfrom="Celsius" then
if tto="Celsius" then tempout=temp
if tto="Fahrenheit" then tempout= 1.80 * temp + 32
if tto="Kelvin" then tempout= temp + 273.15
if tto="Rankine" then tempout= 1.80 * (temp + 273.15)
endif
if tfrom="Fahrenheit" then
if tto="Celsius" then tempout= 5 / 9 * (temp - 32)
if tto="Fahrenheit" then tempout=temp
if tto="Kelvin" then tempout= 5 / 9 * (temp - 32) + 273.15
if tto="Rankine" then tempout=temp + 459.67
endif
if tfrom="Kelvin" then
if tto="Celsius" then tempout= temp - 273.15
if tto="Fahrenheit" then tempout= 1.80 * (temp - 273.15) + 32
if tto="Kelvin" then tempout=temp
if tto="Rankine" then tempout=1.80 * temp
endif
if tfrom="Rankine" then
if tto="Celsius" then tempout=temp / 1.80 - 273.15
if tto="Fahrenheit" then tempout= temp - 459.67
if tto="Kelvin" then tempout= temp/1.80
if tto="Rankine" then tempout=temp
endif
end
func getmenu
pen on
repeat
if pen(0)
x=pen(4):y=pen(5)
if (x>10 and x<100) and ((y>25 and y<50) or (y>55 and y<80) or (y>85 and y<110) or (y>115 and y<140)) then
if y<50 then : getmenu="Celsius"
elseif y<80 then : getmenu="Fahrenheit"
elseif y<110 then : getmenu="Kelvin"
elseif y<140 then : getmenu="Rankine"
endif
exit loop
endif
endif
until
pen off
end'