Contents Up Previous Next

Using wxCLIPS as a library

The library is used by including the header file wx_cmds.h and linking with libcmds.a or wxcmds.lib. In addition to the set of new CLIPS functions described in the reference section, there are a few C++ functions to help embed CLIPS.

::ClipsErrorFunction
::RouteCommand
::wxExecuteClipsFile
::wxCleanWindows
::wxInitClips
::wxRouteNoEcho
::wxUserFunctions


::ClipsErrorFunction

void ClipsErrorFunction(char *s)

This function must be defined when using the wxCLIPS library. It will be called whenever a wxCLIPS error occurs to print out a message. The object ClipsError may be used with stream output operators to output error messages; the operators call the ClipsErrorFunction as appropriate.


::RouteCommand

void RouteCommand(char *command, intshowResult)

Internal CLIPS command modified to be 're-entrant'. Takes a string containing a CLIPS command and executes it. This function cannot return a result from CLIPS on its own, but used in conjunction with the wxCLIPS function return-result and some predefined global variables the same effect can be achieved. For example,

  wxFrame *main_frame = NULL;
  clipsReturnType = clipsUNKNOWN;
  RouteCommand("(return-result (app-on-init))");
  if (clipsReturnType == clipsLONG)
  {
    main_frame = (wxFrame *)wxGetTypedObject(clipsReturnLong, wxTYPE_FRAME);
  }
See the entry for return-result for more details.


::wxExecuteClipsFile

void wxExecuteClipsFile(char *filename)

Execute a CLIPS batch file.


::wxCleanWindows

void wxCleanWindows(void)

Deletes wxWindows frames and dialog boxes created with CLIPS functions, allowing an application to be restarted from the wxCLIPS environment or the user's environment.


::wxInitClips

void wxInitClips(void)

Call this instead of the normal CLIPS initilization function, to initialize CLIPS and the wxCLIPS library.


::wxRouteNoEcho

void wxRouteNoEcho(char *command)

Calls RouteCommand, but ensures that no echoing of returned results will take place during the call.


::wxUserFunctions

void wxUserFunctions(void)

This function contains the wxCLIPS function definitions. You must call this function from within the UserFunctions function that the CLIPS manual specifies you must define. This allows you to define additional CLIPS functions.