by willeng » Mon Feb 16, 2004 5:20 am
Here's a couple of Q/basic programs that may be of help.
They were given to me.
weather corrections
Calculates Temperature
there are (2) Loops , either computes the same answer
i prefer the 9 Loop version
'| |
'| Program Name: REVERSE.BAS , QBasic/QuickBasic version |
|
'| Purpose: Compute temperature from dewpoint vapor pressure or |
'| from saturation pressure (all in inches Hg.) |
'============================================================================
WIDTH 80 '<--set screen to 80 columns , default
SCREEN 0 '<--set to text screen , default
KEY OFF '<--turn-off 25th line GW-Basic's menu text
VIEW PRINT '<--enable printing on 25th line
LOCATE , , , 7, 7 '<--set cursor to default shape
COLOR 15, 1 '<--bright white on blue
CLS '<--clear entire screen
start:
LOCATE 3, 5
PRINT "Input choices: dewpoint,vapor, or saturation pressure in inches Hg.";
LOCATE 5, 5
PRINT USING "Pressure inches Hg.= ##.###### "; psat;
LOCATE 5, 38
INPUT psat$: IF LEN(psat$) > 0 THEN psat = VAL(psat$)
IF psat = 0 THEN psat = .5216 '<--default value if no input, (60 deg.F)
x = LOG(29.9213 / psat) '<--29.9213 inches Hg. at sea-level at 59 F
b = psat
a = 672 '<- 672 Rankine, (672 = 460 + 212) , 212 F = boiling pt. H2O
c = 35.9381# '<- Constant , 35.913 works with 671.67 and 459.67 (original)
d = -1.152437# '<- Constant , best constant value for d,(-1.152437 orig.)
logicloop:
FOR cnt = 1 TO 25 '<---- 25 is best value for number of loops
t1 = x - (a - b) * c * (b ^ d)
b = b + t1 / (a * c * d * b ^ (d - 1) - c * (d + 1) * b ^ d)
NEXT cnt
dry1 = psat
FOR cnt = 1 TO 9
dry1 = ((x + (c * (dry1 ^ (-.152437)))) / (a * c)) ^ -.867726392#
NEXT
dryb = (dry1 - 460)
LOCATE 10, 5
psatf = b - 460 '<-Fahrenheit conversion from Rankine degrees (459.67 orig.)
PRINT USING "Temperature =####.#### deg.F (####.#) (2nd formula=####.####)"; psatf; psatf; dryb
GOTO start
=================================================================================
Calculates Pressure
, QBasic/QuickBasic version
'| Purpose: Compute vapor pressure or
'| saturation pressure (all in inches Hg.)
'============================================================================
WIDTH 80 '<--set screen to 80 columns , default
SCREEN 0 '<--set to text screen , default
KEY OFF '<--turn-off 25th line GW-Basic's menu text
VIEW PRINT '<--enable printing on 25th line
LOCATE , , , 7, 7 '<--set cursor to default shape
COLOR 15, 1 '<--bright white on blue
CLS '<--clear entire screen
start:
LOCATE 5, 5
PRINT USING "Dry bulb = ###.## "; dryf;
LOCATE 5, 30
INPUT dryf$: IF LEN(dryf$) > 0 THEN dryf = VAL(dryf$)
dryr = 459.67 + dryf
satp = 29.9213 / (EXP((671.67 - dryr) * 35.913 * (dryr ^ -1.152437)))
LOCATE 8, 5
PRINT USING "Saturation pressure =###.###### inches Hg."; satp
LOCATE 9, 5
PRINT USING "Saturation pressure =###.###### psia"; satp / 2.036020696#
LOCATE 10, 5
PRINT USING "Saturation pressure =###.###### mm Hg."; satp * 25.4
GOTO start