WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Conversion UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Pressure Conversions

 Keywords:  Pa bar atm Torr psi 

;***************************************************************************
;; PressureConvert(pressure, "initial2final")
;; 
;; pressure   - any numeric value with arbitrary precision
;;
;; initial2final - 
;***************************************************************************
GOSUB DefineUDFs

;;Debugging Only
mess=""
list="Pa|bar|atm|T|psi"
For ii=1 to 5
	a1%ii%=PressureConvert(1,StrCat("Pa2", ItemExtract(ii,list,"|")))
	mess=StrCat(mess,"1 ", StrCat("Pa2", ItemExtract(ii,list,"|"))," = ",a1%ii%," ",ItemExtract(ii,list,"|"),@CRLF)

	b1%ii%=PressureConvert(1,StrCat("BAR2", ItemExtract(ii,list,"|")))
	mess=StrCat(mess,"1 ", StrCat("BAR2", ItemExtract(ii,list,"|"))," = ",b1%ii%," ",ItemExtract(ii,list,"|"),@CRLF)

	c1%ii%=PressureConvert(1,StrCat("ATM2", ItemExtract(ii,list,"|")))
	mess=StrCat(mess,"1 ", StrCat("ATM2", ItemExtract(ii,list,"|"))," = ",c1%ii%," ",ItemExtract(ii,list,"|"),@CRLF)

	d1%ii%=PressureConvert(1,StrCat("T2", ItemExtract(ii,list,"|")))
	mess=StrCat(mess,"1 ", StrCat("T2", ItemExtract(ii,list,"|"))," = ",d1%ii%," ",ItemExtract(ii,list,"|"),@CRLF)

	e1%ii%=PressureConvert(1,StrCat("PSI2", ItemExtract(ii,list,"|")))
	mess=StrCat(mess,"1 ", StrCat("PSI2", ItemExtract(ii,list,"|"))," = ",e1%ii%," ",ItemExtract(ii,list,"|"),@CRLF)
Next ii

Message(1, mess)
Exit

;***************************************************************************
;***************************************************************************
; Temperature Conversion References
; CRC Handbook:               www.hbcpnetbase.com/ 
; McDaniels Engineering       http://www.mcdanielcontrols.com
;
;        Pa            bar           atm            Torr            psi
; Pa      1             1.e-5         9.8692e-6      7.5006e-3       1.450377e-4
; bar     1.e5          1             0.98692        750.06          14.50377
; atm     101325        1.01325       1              760             14.69594
; Torr    133.322       1.33322e-3    1.31579E-3     1               19.33672E-3
; psi     6894.757      68.94757E-3   68.046E-3      51.7151          1
;***************************************************************************
;***************************************************************************

:DefineUDFs
#DefineFunction PressureConvert(pressure, fromto)
	Decimals(-3)	;; Use Scientific Notation
	conversion=1

	If StrUpper(fromto)=="PA2BAR"  then conversion=   1.0e-5
	If StrUpper(fromto)=="PA2ATM"  then conversion=   9.8692e-6
	If StrUpper(fromto)=="PA2T"    then conversion=   7.5006e-3
	If StrUpper(fromto)=="PA2PSI"  then conversion=   1.450377e-4
	If StrUpper(fromto)=="BAR2PA"  then conversion=   1.0e5
	If StrUpper(fromto)=="BAR2ATM" then conversion=   0.98692
	If StrUpper(fromto)=="BAR2T"   then conversion= 750.06
	If StrUpper(fromto)=="BAR2PSI" then conversion=  14.50377
	If StrUpper(fromto)=="ATM2PA"  then conversion= 101.325e3
	If StrUpper(fromto)=="ATM2BAR" then conversion=   1.01325
	If StrUpper(fromto)=="ATM2T"   then conversion= 760.0
	If StrUpper(fromto)=="ATM2PSI" then conversion=  14.69594
	If StrUpper(fromto)=="T2PA"    then conversion= 133.322
	If StrUpper(fromto)=="T2BAR"   then conversion=   1.33322e-3
	If StrUpper(fromto)=="T2ATM"   then conversion=   1.31579E-3
	If StrUpper(fromto)=="T2PSI"   then conversion=  19.33672E-3
	If StrUpper(fromto)=="PSI2PA"  then conversion=6894.757
	If StrUpper(fromto)=="PSI2BAR" then conversion=  68.94757E-3
	If StrUpper(fromto)=="PSI2ATM" then conversion=  68.046E-3
	If StrUpper(fromto)=="PSI2T"   then conversion=  51.7151

	pressure=pressure*conversion

	Return pressure
#EndFunction

Return

Article ID:   W15005
File Created: 2001:11:08:12:41:20
Last Updated: 2001:11:08:12:41:20