⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
   /*-------------+   | Focus Window |   +-------------*/    WinFocus.hWnd = CreateWindow( "StatusWClass", "Focus",      WS_THICKFRAME | WS_MAXIMIZEBOX | WS_CAPTION | WS_VSCROLL | WS_HSCROLL,      0, 0, 0, 0, NULL, NULL, hInstance, NULL);   if (!WinFocus.hWnd)      return (FALSE);   hDC = GetDC ( WinFocus.hWnd);   SelectObject (hDC, GetStockObject(SYSTEM_FIXED_FONT));   GetTextMetrics(hDC, &tm);   ReleaseDC ( WinFocus.hWnd, hDC );   WinFocus.LineSize = ( tm.tmHeight + tm.tmExternalLeading );   WinFocus.NoLines = 0;   ShowWindow(WinFocus.hWnd,  SW_HIDE );#endif   /*-----+   | Misc |   +-----*/   SetScrollRange ( WinDialog.hWnd, SB_VERT, WinDialog.NoLines-1, WinDialog.NoLines, TRUE );   WAIT[0] = LoadCursor ( hInst, "CURSOR0" );   WAIT[1] = LoadCursor ( hInst, "CURSOR1" );   WAIT[2] = LoadCursor ( hInst, "CURSOR2" );   WAIT[3] = LoadCursor ( hInst, "CURSOR3" );   WAIT[4] = LoadCursor ( hInst, "CURSOR4" );   WAIT[5] = LoadCursor ( hInst, "CURSOR5" );   WAIT[6] = LoadCursor ( hInst, "CURSOR6" );   WAIT[7] = LoadCursor ( hInst, "CURSOR7" );   WAIT[8] = LoadCursor ( hInst, "CURSOR8" );   WAIT[9] = LoadCursor ( hInst, IDC_WAIT );   QUERY = LoadCursor (hInst, "CLIPS_QUERY");   ARROW = LoadCursor ( NULL, IDC_ARROW );   UpdateCursor ( ARROW_CURSOR );   return (TRUE);}/***************************************************************** WinOutOfMemoryFunction ( size ): Function which is called when*   CLIPS runs out of memory.  Clips will not attempt to allocate*   the memory again and will exit.** size - size of memory request that could not be satisfied.****************************************************************/#if IBM_TBC#pragma argsused#endifint WinOutOfMemoryFunction( unsigned long int size ){    extern SCREEN WinDialog;     MessageBeep(0);     MessageBox ( WinDialog.hWnd, "CLIPS is out of memory!!", "-WARNING-", MB_ICONHAND | MB_OK );     return (1);}/***************************************************************** ExitToShell:  Quit Clips and return to OS*****************************************************************/void ExitToShell( void ){  extern SCREEN WinDialog;   MessageBeep(0);   MessageBox (WinDialog.hWnd, "CLIPS is out of memory!!", "-ERROR-", MB_ICONHAND | MB_OK );   PostMessage (WinDialog.hWnd, WM_COMMAND, IDM_FILE_QUIT, NULL);}/********************************************************* SetCompletionDialogCommand: Turns on/off the option for*   using the Completion WinDialog.*********************************************************/int SetCompletionDialogCommand( VOID ){  extern BOOL Complete;   int oldValue;   DATA_OBJECT argPtr;   oldValue = Complete;   if ( ArgCountCheck ("set-completion-dialog", EXACTLY, 1 ) == -1 )      return ( oldValue );   RtnUnknown (1,&argPtr );   if ((argPtr.value == CLIPSFalseSymbol ) && (argPtr.type == SYMBOL))      Complete = FALSE;   else      Complete = TRUE;   return (oldValue);}/********************************************************* SetJoeWarningsCommand: Turns on/off the option for*   using the Yes/No Joe warning Dialog.*********************************************************/int SetJoeWarningsCommand(){  extern int warnings;   int oldvalue;   DATA_OBJECT ArgPtr;   oldvalue = warnings;   if (ArgCountCheck ("set-joe-warnings",EXACTLY,1) == -1)      return (oldvalue);   RtnUnknown(1,&ArgPtr);   if((ArgPtr.value == (VOID *) CLIPSFalseSymbol) && (ArgPtr.type == SYMBOL))      warnings = CLIPS_FALSE;   else      warnings = CLIPS_TRUE;   return ( warnings );}/******************************************************************** DefineWinFunctions: Creates CLIPS command line functions*   for use of interface options.*******************************************************************/VOID DefineWinFunctions ( VOID ){  DefineFunction2 ("clear-window", 'v', PTIF ClearDialogWnd, "ClearDialogWnd", "00" );   DefineFunction2 ("set-completion-dialog",'b', SetCompletionDialogCommand, "SetCompletionDialogCommand", "11");   DefineFunction2 ("set-joe-warnings", 'b', SetJoeWarningsCommand, "SetJoeWarningsCommand", "11");   DefineFunction2 ("winhelp", 'v', PTIF WinHelp2, "WinHelp2", NULL);}/**************************************************************** UserFunctions:  The function which informs CLIPS of any   *   user defined functions.  In the default case, there are *   no user defined functions.  To define functions, either *   this function must be replaced by a function with the   *   same name within this file, or this function can be     *   deleted from this file and included in another file.    *   User defined functions may be included in this file or  *   other files.                                            *   Example of redefined UserFunctions:                     *     UserFunctions()                                       *       {                                                   *        DefineFunction("fun1",'i',fun1,"fun1");            *        DefineFunction("other",'f',other,"other");         *       }                                                   *****************************************************************/VOID UserFunctions(){}/******************************************************************** WinWaitEvent: Executes one pass of the main program loop.*******************************************************************/int WinWaitEvent ( VOID ){  extern SCREEN WinDialog;#if ! WIN_32	static BOOL MemoryOK = TRUE;#endif   extern HANDLE hAccTable;   MSG msg;   UpdateCursor ( ARROW_CURSOR );   /*------------------------------------+   | Update Status window and Menu Items |   +------------------------------------*/   UpdateStatus();   UpdateMenu();   /*------------------+   | Handle Next Event |   +------------------*/   GetMessage (&msg, NULL, NULL, NULL );   if (!TranslateAccelerator(WinDialog.hWnd, hAccTable, &msg))   {  TranslateMessage (&msg);      DispatchMessage (&msg);   }   /*--------------------------------------+   | Check to see if memory is running low |   +--------------------------------------*/#if ! WIN_32   if (GlobalCompact( NULL ) < (30L * 1024L) && MemoryOK )   {   MemoryOK = FALSE;       MessageBeep (0);       MessageBox ( WinDialog.hWnd, "Quit as soon as possible",	  "CLIPS is running out of memory", MB_OK | MB_ICONHAND );	}#endif   return (TRUE);}/******************************************************************** WinRunEvent: Execution function which is called between rule*    firings by CLIPS to update the interface.*******************************************************************/VOID WinRunEvent ( VOID ){  MSG msg;   extern SCREEN WinDialog;   extern HANDLE hAccTable;   extern int ApplicationFocus;   UpdateMenu();   UpdateStatus();   while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))   {  if (!TranslateAccelerator(WinDialog.hWnd, hAccTable, &msg))      {  TranslateMessage (&msg);	 DispatchMessage (&msg);      }   }}/****************************************************************//* InitializeKeywords: Adds CLIPS key words to the symbol table *//*   so that they are available for command completion.         *//****************************************************************/static void InitializeKeywords(){#if ! RUN_TIME   void *ts;   /*====================*/   /* Interface keywords */   /*====================*/   ts = AddSymbol("set-completion-dialog");   IncrementSymbolCount(ts);   ts = AddSymbol("set-joe-warnings");   IncrementSymbolCount(ts);   ts = AddSymbol("clear-window");   IncrementSymbolCount(ts);#endif}/******************************************************************** SetUpRouters:  Creates and Renames I/O routers for use*    with the Windows Interface*******************************************************************/VOID SetUpRouters ( VOID ){     AddRouter ("stdin",   20, QueryFunction, PrintFunction, GetCFunction, NULL, ExitFunction);}/******************************************************************** QueryFunction: Call back function used to recognize logical names*    for interface defined routers.*******************************************************************/int QueryFunction ( char * logicalname ){  if ( strcmp (logicalname, "wclips")==0)      return 1;   else if ( strcmp (logicalname, "stdout")==0)      return 1;   else if ( strcmp (logicalname, "stdin")==0)      return 1;   else if ( strcmp (logicalname, "wdialog")==0)      return 1;   else if ( strcmp (logicalname, "wdisplay")==0)      return 1;   else if ( strcmp (logicalname, "wtrace")==0)      return 1;   else if ( strcmp (logicalname, "werror")==0)      return 1;   else if ( strcmp (logicalname, "wwarning")==0)      return 1;   return 0;}/******************************************************************** ExitFunction: Routine to  check an exit from the dialog window*  to make sure that the user has an opportunity to save files.*******************************************************************/#if IBM_TBC#pragma argsused#endifint ExitFunction ( int exitcode ){  extern SCREEN WinDialog;   PostMessage ( WinDialog.hWnd, WM_COMMAND, IDM_FILE_QUIT, NULL);   return (0); }/******************************************************************** GetCFunction: Function is called whenever clips needs input*   from the keyboard.  Function will setup an event loop and*   will process character input.  Return value is the ASCII*   code for the character received.*******************************************************************/#if IBM_TBC#pragma argsused#endifint GetCFunction ( char * logicalname ){ MSG msg;  extern HCURSOR QUERY;  extern HANDLE hAccTable;  static int count = 0;  UpdateCursor ( QUESTION_CURSOR );  GetMessage ( &msg, NULL,0,0);  TranslateMessage (&msg);  while (TRUE)  {  if (msg.message == WM_CHAR )     {  switch ( msg.wParam )	{  case VK_BACK:			 GetUserCmd ( (WORD) msg.wParam, TRUE, count);	       count --;	       if ( count < 0 ) count = 0;	       msg.wParam = '\b';	       break;	    case VK_RETURN:	       GetUserCmd ( msg.wParam, TRUE, count);	       count = 0;	       UpdateCursor ( ARROW_CURSOR );	       msg.wParam = '\n';	       break;	    default:	       count ++;	       GetUserCmd ( msg.wParam, TRUE, count);	       break;	}	return (msg.wParam);     }     DispatchMessage ( &msg );     UpdateCursor ( QUESTION_CURSOR );     GetMessage(&msg, NULL, 0, 0);     TranslateMessage (&msg);  }}/******************************************************************** StartWaitCursor: Function is called to set an event timer*   used to update the animated wait cursor.*******************************************************************/VOID StartWaitCursor ( VOID ){  extern SCREEN WinDialog;   SetTimer(WinDialog.hWnd, IDT_UPDATEWAIT, 500, (TIMERPROC)NULL);}/******************************************************************** StopWaitCursor: Function is called to stop the event timer*   used to update the animated wait cursor.*******************************************************************/VOID StopWaitCursor ( VOID ){  extern SCREEN WinDialog;   extern HCURSOR ARROW;   KillTimer(WinDialog.hWnd, IDT_UPDATEWAIT);   NowCursor = ARROW;   SetCursor ( ARROW);}/******************************************************************** StopWaitCursor: Function is called everytime the event timer*   activates to update the wait cursor.*******************************************************************/VOID UpdateCursor ( int Cursor ){  extern HCURSOR WAIT[], ARROW, QUERY, NowCursor;   switch ( Cursor )   {  case ARROW_CURSOR:    NowCursor = ARROW;   break;      case QUESTION_CURSOR: NowCursor = QUERY;   break;      case WAIT_CURSOR:     NowCursor = WAIT[0]; break;   }   SetCursor ( NowCursor );}/******************************************************************** WinHelp2: Callback function used to provide a commmand line*   interface to the Windows Help Facility. *******************************************************************/VOID WinHelp2 (VOID){  extern SCREEN WinDialog;   switch ( RtnArgCount () )   {  case 1:      {  LPSTR String;	 String = (LPSTR) RtnLexeme ( 1 );	 if ( String != NULL )	 {  WinHelp (WinDialog.hWnd, "CLIPS6.HLP", HELP_KEY, (DWORD) String);	    break;	 }      }      case 0:      {  WinHelp (WinDialog.hWnd, "CLIPS6.HLP", HELP_INDEX, NULL);	 break;      }      default:      {  MessageBeep(0);	 break;      }   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -