Exemple #1
0
globle VOID RerouteStdin2(int argc, char** argv)  /*int argc; char *argv[];*/
{
   int i;
   /* If no arguments return */
   if (argc < 3) { return; }
   /* If argv was not passed then forget it */
   if (argv == NULL) return;

   for (i = 1 ; i < argc ; i++)
   {   
      if (strcmp(argv[i],"-r") == 0)
      {
         if (i > (argc-1))
         {
            PrintErrorID("SYSDEP",1,CLIPS_FALSE);
            PrintCLIPS(WERROR,"No string found for -r option\n");
            return;
         }
         else
	 {
	    printf("Doing a: RouteCommand(%s)\n",argv[++i]); fflush(stdout);
	    RouteCommand(argv[i]);
	 }
      }
   }
}
Exemple #2
0
long DoLoad ( HWND hMain, WORD LoadType)

{  OPENFILENAME ofn;
   extern HANDLE hInst;
   char File[256], FileTitle[256], Filter[256];
   UINT i, cbString;
   char Replace;

   File[0] = '\0';
   memset ( &ofn,0, sizeof (OPENFILENAME));

   /*---------------------------------------------+
   | Initialize Common Dialog based on File Type. |
   +---------------------------------------------*/
   switch ( LoadType )
   {  case IDM_FILE_LOAD:
      {  ofn.lpstrTitle = "Load CLIPS Constructs";
         if ((cbString = LoadString ( (HINSTANCE) hInst, IDS_RULES, Filter, sizeof (Filter))) == 0 )
            return 0L;
	 break;
      }

      case IDM_FILE_LBATCH:
      {  ofn.lpstrTitle = "Load CLIPS Batch File";
         if ((cbString = LoadString ( (HINSTANCE) hInst, IDS_BATCH, Filter, sizeof (Filter))) == 0 )
	    return 0L;
	 break;
      }

      case IDM_FILE_LBINARY:
      {  ofn.lpstrTitle = "Load CLIPS Binary File";
         if ((cbString = LoadString ( (HINSTANCE) hInst, IDS_BINARY, Filter, sizeof (Filter))) == 0 )
	    return 0L;
         break;
      }
   }

   Replace = Filter[cbString-1];

   for (i=0; Filter[i] != '\0'; i++)
      if ( Filter[i] == Replace)
         Filter[i] = '\0';

   ofn.lStructSize = sizeof ( OPENFILENAME );
   ofn.hwndOwner = hMain;
   ofn.lpstrFilter = Filter;
   ofn.nFilterIndex = 1;
   ofn.lpstrFile = File;
   ofn.nMaxFile = sizeof (File );
   ofn.lpstrFileTitle = FileTitle;
   ofn.nMaxFileTitle = sizeof (FileTitle);
   ofn.lpstrInitialDir = NULL;
   ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;


   /*--------------------+
   | Issue CLIPS Command |
   +--------------------*/
   if ( GetOpenFileName ( &ofn ) )
   {  int x, size;

      UpdateCursor(WAIT_CURSOR);
      /*-----------------+
      | Adjust Path Info |
      +-----------------*/
      size = strlen(ofn.lpstrFile );
      for ( x=0; x<size ; x++)
         if ( ofn.lpstrFile [x] == '\\' )
            ofn.lpstrFile [x] = '/';

      switch ( LoadType )
      {  case IDM_FILE_LOAD:
            SetCommandString("(load \"");  break;
         case IDM_FILE_LBATCH:
            SetCommandString("(batch \""); break;
         case IDM_FILE_LBINARY:
            SetCommandString("(bload \""); break;
      }
      AppendCommandString ( ofn.lpstrFile );
      AppendCommandString ( "\")\n");
      PrintCLIPS ( "stdout", GetCommandString());
      UpdateCursor ( ARROW_CURSOR );
      PrintPrompt();
   }
   return 0L;
}
Exemple #3
0
void GetUserCmd ( 
  WORD wParam,      /* Key Code */
  BOOL ScreenOnly,  /* Send to Screen and or Command Buffer */
  int  InputSize)   /* Number of characters send to screen only */

  {
	extern int HorizScroll; /* Automatic Scrolling Enabled/Disabled */

	switch (wParam)
	  {
		extern SCREEN WinDialog;
		extern int UserInput;

		/*------------------+
		| Handle Back Space |
		+------------------*/

		case VK_BACK:
		  {
			/*-----------------------------------------------+
			| Init Values when sending to the command buffer |
			+-----------------------------------------------*/
			if (! ScreenOnly)
			  {
				HorizScroll = 1;
				if (GetCommandString() != NULL)
				  { InputSize = strlen(GetCommandString()); }
				else
				  { InputSize = 0; }
			  }

	 if (InputSize > 0 )
	 {
		 int size;

		 if (Terminal[WinDialog.LastLine] != NULL)
			{ size = strlen(Terminal[WinDialog.LastLine]); }
		 else
			{ size = 0; }

		 if (!ScreenOnly)
			 ExpandCommandString ('\b');

		 if (size > 0)
			 Terminal[WinDialog.LastLine][size - 1] = '\0';
		 else
		 {  int min, max;
			 extern int OldLine;

			 if ( Terminal[WinDialog.LastLine] != NULL )
			 {
		free(Terminal[WinDialog.LastLine]);
		Terminal[WinDialog.LastLine] = NULL;
	       }

			 WinDialog.LastLine --;
	       OldLine --;

	       if ( WinDialog.LastLine < 0 )
		  WinDialog.LastLine = DIALOG_SIZE;

	       GetScrollRange (WinDialog.hWnd, SB_VERT, &min, &max);
	       if ( WinDialog.NoLines < max && max < DIALOG_SIZE )
	       {  SetScrollRange ( WinDialog.hWnd, SB_VERT, WinDialog.NoLines, max-1, FALSE );
		  SetScrollPos   ( WinDialog.hWnd, SB_VERT, max-1, FALSE );
	       }
	       InvalidateRect ( WinDialog.hWnd, NULL, TRUE );
		 }
		 SendToScreen();
	 }
	 break;
      }

      /*--------------------------+
      | Remove Special Keys (ALT) |
      +--------------------------*/
      case '\f':
      case VK_MENU:
	 break;


      /*----------------+
      | Handle Tab Keys |
      +----------------*/
      case '\t':
		{  if ( !ScreenOnly)
	 {  if ( GetCommandString() == NULL)
	       SetCommandString("   ");
	    else
	       AppendCommandString("   ");
	 }
	 PrintCLIPS ("stdout", "   " );
	 break;
      }


      /*---------------------+
      | Return / Newline Key |
      +---------------------*/
      case '\r':
      case '\n':
      {  wParam = (int)'\n';
	 if (GetScrollPos (WinDialog.hWnd, SB_HORZ) != 0)
	 {  SetScrollPos ( WinDialog.hWnd, SB_HORZ, 0, TRUE );
	    InvalidateRect(WinDialog.hWnd, NULL, FALSE);
	    SendMessage ( WinDialog.hWnd, WM_PAINT, 0, 0 );
	 }
      }

      /*---------------------+
      | All other characters |
      +---------------------*/
      default:
      {  char text[2];

	 text[0] = (char) wParam;
	 text[1] = '\0';

	 if(isprint ( text[0]) || isspace (text[0]))
	 {  /*----------------------------+
	    | Add to CLIPS Command Buffer |
		 +----------------------------*/

	    if (!ScreenOnly)
	    {  if ( GetCommandString() == NULL)
		  SetCommandString(text);
	       else
		  AppendCommandString(text);
		 }

		 PrintCLIPS ("stdout", text );
	 }
	 break;
		}
	}
	HorizScroll = 0;
}