
A1.5 Adding a user-friendly interface with Visual C
++
13
// ... FnGetRanAppSettings listed below ...
// replaces standard Ox exit function
// ... part deleted ...
extern "C" void OXCALL OxRunOxExit(int i)
{
AfxMessageBox( "Ox run-time error" );
AfxThrowUserException( );
}
static int iDoOxRun(LPCTSTR sExePath)
{
CString soxfile = "-r- ";
soxfile += sExePath;
soxfile.Replace(".exe", ".ox");
g_iMainIP = 0;
// Must startup GiveWin and install linking functions
if (!FOxGiveWinStart("RanApp", "RanApp", FALSE))
return 0; // fail if cannot start GiveWin
SetOxExit(OxRunOxExit); // replace exit function
FOxLibAddFunction("ccc$GetRanAppSettings",
FnGetRanAppSettings, 0); // install new function
g_iMainIP = OxMainCmd(soxfile);//"-r- path\ranapp.ox"
if (g_iMainIP <= 1)
{
AfxMessageBox( "Ox compilation error" );
}
return g_iMainIP;
}
.......................................................................................
• iDoOxRun simulates a call to Ox with command line arguments comparable to
running Ox from the command line.
• FOxGiveWinStart starts GiveWin for Ole automation communication. When
successful, Ox calls to print and graphics functions will appear in GiveWin.
FOxGiveWinStart resides in OxGiveWin2.dll.
• Next, we set up the command line. The first argument is always the name of the
program, so is not really important. The second argument, argument 1, is the
name of the Ox code to compile; that code is in ranapp.ox, and here the full
path name is obtained from the sExePath string. The third argument prevents
the Ox program from running, restricting to a compile and link only.
• SetOxExit replaces the default OxExit function with a new version.
• FOxLibAddFunction adds FnGetRanAppSettings as a function which can be
called from the Ox code as GetRanAppSettings.Theccc before the dollar
Kommentare zu diesen Handbüchern