Saturday, February 1, 2020

Sample code

label 1;
var
T1,Rh1,RH2,T2,T1c,ht,Psat1,Psat2,Pv,Tdew,Psat:extended;
errors1:boolean;
calcstr2,calcstr1:string[30];
begin
errors1:=false;
form4.hide;
form4.show;
{form4.Memo1.clearselection};
try
T1:=strtofloat(form4.edit1.Text);
Rh1:=strtofloat(form4.edit2.Text);
T2:=strtofloat(form4.edit3.Text);
except
errors1:=true;
end;
if (errors1=true) or
(t1<0.01) or (t1>69) or (rh1<0) or (rh1>100) or
(t2<0.1) or (t2>70) or (T2<T1+0.02)
then begin
form4.Memo1.Lines.Add('CHECK ENTRIES.');
goto 1
end;
T1C:=T1;
ht:=1000*(T2-T1)/3.3;
RH1:=RH1/100;
Psat1:=0.61121*exp((18.678-T1/234.5)*T1/(257.14+T1));
Pv:=Psat1*RH1;
Psat2:=0.61121*exp((18.678-T2/234.5)*T2/(257.14+T2));
Rh2:=Pv/Psat2;  {ie partial pressure of water vapour/psat2}
str(rh2*100:9:2,calcstr1);
form4.Memo1.lines.Add('Final relative humidity (at T2) is: '+calcstr1+'%.');
Tdew:=T1;
repeat
Tdew:=Tdew-0.001;
Psat:=0.61121*exp((18.678-Tdew/234.5)*Tdew/(257.14+Tdew));
until (Psat<=Pv);
str(Tdew:12:2,calcstr2);
form4.Memo1.Lines.Add('Dew point is: '+calcstr2+' deg C.');
1: end;

No comments:

Post a Comment