
A1.5 Adding a user-friendly interface with Visual C
++
15
..............................................ox/dev/windows/ranapp/RanApp.ox
#include <oxstd.h>
#include <oxdraw.h>
GetRanAppSettings(const acT, const acN, const acAcf);
static decl s_mX;
static decl s_cT = 30;
static decl s_cN = 2;
static decl s_cAcf = 4;
OnDimension()
{
if (GetRanAppSettings(&s_cT, &s_cN, &s_cAcf))
println("T = ", s_cT, " n = ", s_cN,
" lag length = ", s_cAcf);
}
OnGenerate()
{
s_mX = rann(s_cT, s_cN);
}
OnVariance()
{
print( variance(s_mX) );
}
OnDraw()
{
DrawCorrelogram(0, s_mX[][0]’, "ran1", s_cAcf);
DrawSpectrum(1, s_mX[][0]’, "ran1", s_cAcf);
ShowDrawWindow();
}
.......................................................................................
• Eventough GetRanAppSettings() is defined, it still has to be declared.
• OnDimension() calls GetRanAppSettings() to get new values, printing the
new settings if successful. The arguments are passed as references so that they
may be changed. The C
++
code is:
.........................................................................
extern "C" void OXCALL FnGetRanAppSettings(
OxVALUE *rtn, OxVALUE *pv, int cArg)
{
CRanDimDlg dlg;
OxLibCheckType(OX_ARRAY, pv, 0, 2);
OxLibCheckType(OX_INT, OxArray(pv, 0), 0, 0);
OxLibCheckType(OX_INT, OxArray(pv, 1), 0, 0);
OxLibCheckType(OX_INT, OxArray(pv, 2), 0, 0);
// initialize dialog with current settings
dlg.m_cT = OxInt(OxArray(pv, 0), 0);
dlg.m_cDim = OxInt(OxArray(pv, 1), 0);
Komentarze do niniejszej Instrukcji