Page Date
2004-05-18
DD-Software
Kapitel zurück / previous Chapter
Main Index
 
Seite zurück / previous page
Backward
Seite vor / next page
Forward
 
Seitenanfang/TopOfPage
Top
Seitenende/EndOfPage
Bottom
MyWbtHelp current version

WinBatch Scripting - Conversion Functions



Seitenanfang/TopOfPage Seitenende/EndOfPage Seitenende/EndOfPage Seitenanfang/TopOfPage

Pressure Conversion

;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udfpressureconvert",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udfpressureconvert

#DefineFunction udfPressureConvert (fPressure, sDimFrom, sDimTo)
sDimList = "pa/bar/at/atm/t/ws/psi"
sDimFrom = StrLower(sDimFrom)
iFrom = ItemLocate(sDimFrom,sDimList,"/")
Terminate(iFrom==0,'udfPressureConvert',StrCat('Allowed dimensions = ',sDimList,@LF,'Failure at: DimFrom="',sDimFrom,'"'))
sDimTo = StrLower(sDimTo)
iTo = ItemLocate(sDimTo,sDimList,"/")
Terminate(iTo==0,'udfPressureConvert',StrCat('Allowed dimensions = ',sDimList,@LF,'Failure at: DimTo="',sDimTo,'"'))

row1 = "1.000000e+0/1.000000e-5/1.0197162129779282e-5/9.869200e-6/7.5006168270416975e-3/1.0197162129779282e-1/1.450377e-4" ; pa
row2 = "1.000000e+5/1.000000e+0/1.0197162129779282e+0/9.896200e-1/7.5006168270416975e+2/1.0197162129779282e+4/1.450377e+1" ; bar
row3 = "9.806650e+4/9.806650e-1/1.0000000000000000e+0/9.678000e-1/7.3555924006908462e+2/1.0000300009000270e+4/1.422333e+1" ; at
row4 = "1.013250e+5/1.013250e+0/1.0332713370531101e+0/1.000000e+0/7.6000000000000000e+2/1.0332274527998857e+4/1.469594e+1" ; atm
row5 = "1.333220e+2/1.333220e-3/1.3594344752582925e-3/1.315790e-3/1.0000000000000000e+0/1.3600000000000000e+1/1.933672e-2" ; torr
row6 = "9.806650e+0/9.806650e-5/9.9997000000000000e-5/9.678000e-5/7.3555924006908462e-2/1.0000000000000000e+0/1.422334e-3" ; ws
row7 = "6.894757e+3/6.894757e-2/7.0306954974430615e-2/6.804596e-2/5.1714930372563533e+1/7.0306954974430615e+2/1.000000e+0" ; psi

fConvertFactor = 1.0
If (iFrom>0) Then If (iTo>0) Then fConvertFactor = ItemExtract(iTo,row%iFrom%,"/")
Return (fPressure*fConvertFactor)
;..........................................................................................................................................
; This function udfPressureConvert() returns converted value for parameter fPressure
; fPressure = any numeric value with arbitrary precision
; sDimFrom and sDimTo are keywords from sDimList="Pa/bar/at/atm/T/WS/psi", e.g."pa" or "psi"
;
; Usage: fResult = udfPressureConvert(123.45,"psi","bar")
;
; Detlev Dalitz.20020203
;..........................................................................................................................................
#EndFunction
:skip_udfpressureconvert


;--- test---
iLastDecimals = Decimals(-3) ; Use Scientific Notation.
sStringOut = ""
sDimList = "Pa/bar/at/atm/T/WS/psi"
fPressure = 1.0
For i=1 To 7
   For k=1 To 7
      sDimFrom = ItemExtract(i,sDimList,"/")
      sDimTo   = ItemExtract(k,sDimList,"/")
      fResult  = udfPressureConvert(fPressure,sDimFrom,sDimTo)
      sStringOut = StrCat(sStringOut,fPressure,@TAB,sDimFrom,@TAB,"= ",fResult,@TAB,sDimTo,@LF)
   Next
   sStringOut = StrCat(sStringOut,@LF)
Next
IntControl (63,250,50,750,950) ; Sets coordinates for AskItemList.
AskItemlist("Pressure Conversion",sStringOut,@LF,@UNSORTED,@SINGLE)
:CANCEL
Decimals(iLastDecimals)
Exit
;------------------------------------------------------------------------------------------------------------------------------------------
*EOF*


Seitenanfang/TopOfPage Seitenende/EndOfPage Seitenende/EndOfPage Seitenanfang/TopOfPage

Temperature Conversion

;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udftemperatureconvert",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udftemperatureconvert

#DefineFunction udfTemperatureConvert (fDegrees, sDimFrom, sDimTo)
sDimList = "c/f/k/r"
sDimFrom = StrLower(sDimFrom)
iFrom = ItemLocate(sDimFrom,sDimList,"/")
Terminate(iFrom==0,'udfTemperatureConvert',StrCat('Allowed dimensions = ',sDimList,@LF,'Failure at: DimFrom="',sDimFrom,'"'))
sDimTo = StrLower(sDimTo)
iTo = ItemLocate(sDimTo,sDimList,"/")
Terminate(iTo==0,'udfTemperatureConvert',StrCat('Allowed dimensions = ',sDimList,@LF,'Failure at: DimTo="',sDimTo,'"'))

Goto %sDimFrom%_%sDimTo%
:c_f
Return ((1.80*fDegrees)+32.0)
:c_k
Return (fDegrees+273.15)
:c_r
Return (1.80*(fDegrees+273.15))
:f_c
Return ((fDegrees-32.0)*(5.0/9.0))
:f_k
Return (((fDegrees-32.0)*(5.0/9.0))+273.15)
:f_r
Return (fDegrees+459.67)
:k_c
Return (fDegrees-273.15)
:k_f
Return (((9.0/5.0)*(fDegrees-273.15))+32)
:k_r
Return ((9.0/5.0)*fDegrees)
:r_c
Return (((5.0/9.0)*fDegrees)-273.15)
:r_f
Return (fDegrees-459.67)
:r_k
Return ((5.0/9.0)*fDegrees)
:c_c
:f_f
:k_k
:r_r
Return (fDegrees)
;..........................................................................................................................................
; fDegrees = any numeric value, makes no allowance for absolute zero
; sDimFrom and sDimTo are keywords from sDimList="c/f/k/r", e.g."c" or "r"
; with C = Celsius, K = Kelvin, F = Fahrenheit, R = Rankine.
;
; Adapted from database Wilson WinWare Tech BBS
; Published by Craig Storey."2001:03:23:17:14:00" cstorey@canada.com
; Modified by Detlev Dalitz."2001:03:24:14:45:00" dd@dalitz-im-netz.de
; Modified by Detlev Dalitz."2002:02:03:19:29:00" dd@dalitz-im-netz.de
;..........................................................................................................................................
; Temperature Conversion References
; CRC Handbook:               www.hbcpnetbase.com/
; NRC Measurement Standards:  www.thermometry.inms.nrc.ca/thermometry/ITS-90.htm
;
; Celsius=(Fahrenheit-32)*(5/9), Defined by Water bp=100C, fp=0C
; Fahrenheit=(9/5)*Celsius +32,  Defined by Water bp=212F, fp=32F
; Kelvin=Celsius+273.15          Define Zero entropy at 0K (-273.15C), tp=273.16K, 1K=1C
; Rankine=Fahrenheit+459.67      Define Zero entropy at 0R, 1R=1F
;
;                          Fahrenheit   Celsius    Kelvin   Rankine
; Absolute Zero               -459.67   -273.15      0         0
; Liquid Helium (boiling)     -452.1    -268.9       4.2       7.6
; Liquid nitrogen (boiling    -321.07   -196.0      77.2     138.6
; Water (freezing)              32         0       273.15    491.67
; Water (boiling)              212       100       373.15    671.67
;..........................................................................................................................................
#EndFunction

:skip_udftemperatureconvert
;------------------------------------------------------------------------------------------------------------------------------------------


; --- test ---
iLastDecimals = Decimals(2)
sStringOut = ""
sDimList = "C/F/K/R"
sDegreeList = "0.00/32.00/77.20/671.67"
For i=1 To 4
   For k=1 To 4
      sDimFrom = ItemExtract(i,sDimList,"/")
      sDimTo   = ItemExtract(k,sDimList,"/")
      sDegree  = ItemExtract(i,sDegreeList,"/")
      fResult  = udfTemperatureConvert(sDegree,sDimFrom,sDimTo)
      sStringOut = StrCat(sStringOut,sDegree,@TAB,sDimFrom,@TAB,"= ",fResult,@TAB,sDimTo,@LF)
   Next
   sStringOut = StrCat(sStringOut,@LF)
Next
IntControl (63,300,100,650,700) ; Screen coordinates for AskItemList.
AskItemlist("Temperature Conversion",sStringOut,@LF,@UNSORTED,@SINGLE)
:CANCEL
Decimals(iLastDecimals)
Exit
;------------------------------------------------------------------------------------------------------------------------------------------
*EOF*



Page Date
2004-05-18
DD-Software
Kapitel zurück / previous Chapter
Main Index
 
Seite zurück / previous page
Backward
Seite vor / next page
Forward
 
Seitenanfang/TopOfPage
Top
Seitenende/EndOfPage
Bottom
MyWbtHelp current version