![]() | Sample 3 Array and Table |

PdependsOnH()
FUNCTION PdependsOnH()
SYSTEM(BackGround=995, FontSize=19)
DO step = 1, 80 ! step from 1 to 80
height = (step - 1) * 250 ! in 250m steps
$HeiPres(step, 1) = height
bp = BarometricPressure(height)
$HeiPres(step, 2) = bp
ENDDO
F2()
F3()
F4()
END
FUNCTION F2() ! standard loop graph demonstrates single step plotting
DLG(R=2,C=4,BackG=99, AXis=3, X=1,MIN=0,MAX=8000,TIt='LINE call per data point', Y=1,MIN=300,MAX=1100)
DO i = 0, 8000, 250
height = i
pressure = BarometricPressure(height)
LINE(AX=3, X=height, Y=pressure, Symbol='○', Width=3, Draw=-900)
ENDDO
END
FUNCTION F3() ! internal $ loop variable, depends on matrix $HeiPres(height, pressure)
DLG(R=2,C=4,BackG=990, AXis=4, X=1,TI='altitude/m',MAX=8000,TIt='1 LINE call for matrix', Y=1,TI='pressure/hPa',MIN=300,MAX=1100)
LINE(AX=4, Col=1, XVec=$HeiPres, Col=2, YVec=$HeiPres, Symbol='○', Draw=-9)
END
FUNCTION F4() ! show p(h) array and explain
DLG(Nr=5, L=1/2,T=1/2, Array=$HeiPres, TItle=',height / m,barometric pressure / hPa')
DLG(L=0,W=1/2, Nr=6, B='OK, show script', B='Quit HicEst', XEQ='SYSTEM(QUIT=1)', E='#Explain')
END
FUNCTION BarometricPressure(h)
a = 0.0065 ! K/m
T0 = 15 + 273 ! K
M = 0.02896 ! kg/mol
g = 9.81 ! m/s2
R = 8.314 ! J/K/mol = kg*m/s2 /K/mol
P0 = 1013 ! hPa = h N/m2 = h m*kg/s2 /m2
BarometricPressure = P0 * ((1 - a*h/T0) ^ (M*g/R/a))
END
#Explain
We calculate the atmospheric pressure as a function of altitude
You need to know:
. Line 1 is always executed at start.
. A FUNCTION call auto-runs the script.
. This script starts with FUNCTION PdependsOnH()
. To see the code: hit ESCAPE
. All 4 windows are modeless: code does not wait for closure
. NR=.. or AX=.. assign the numbers for modeless windows
A matrix $HeiPres with 81 rows and 2 columns is built
. A matrix column can be either numeric or text
Functions return a value with the RETURN ... statement
Useful to know:
. Rows=r and Cols=c divide the screen in r*c areas
. Nr=wdwNr or AX=axNr will be within this screen area.
. Press F1 over an item to show its value.
. Vectors and matrices are edited with the DLG function.
. Define FUNCTIONs should be at the end of the code.
###