home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Delphi.5 / Samples / sourceD5 / browutil.exe / BROWSER / COMMAND.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-14  |  1.8 KB  |  79 lines

  1. unit Command;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. const
  10.   {CW - Command Window}
  11.   CW_All               : String = 'All';
  12.   CW_Rest              : String = 'Rest';
  13.   CW_Replace           : String = 'Replace';
  14.   CW_For               : String = 'For';
  15.   CW_Update            : String = 'Update';
  16.  
  17. type
  18.   TFrmCommandWindow = class(TForm)
  19.     Memo1: TMemo;
  20.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  21.     procedure Memo1KeyDown(Sender: TObject; var Key: Word;
  22.       Shift: TShiftState);
  23.   private
  24.     { Private declarations }
  25.     procedure RunCommand(sCommand : String);
  26.     procedure GetCommands(sCommand,sFieldName,sValue : String);
  27.   public
  28.     { Public declarations }
  29.   end;
  30.  
  31. var
  32.   FrmCommandWindow: TFrmCommandWindow;
  33.  
  34. implementation
  35.  
  36. uses Menu;
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TFrmCommandWindow.FormClose(Sender: TObject;
  41.   var Action: TCloseAction);
  42. begin
  43.   Action := caFree;
  44. end;
  45.  
  46. procedure TFrmCommandWindow.Memo1KeyDown(Sender: TObject; var Key: Word;
  47.   Shift: TShiftState);
  48. begin
  49.   if (Key = 13) then
  50.     RunCommand(Memo1.Lines.Strings[Memo1.Lines.Count-1]);
  51. end;
  52.  
  53. procedure TFrmCommandWindow.RunCommand(sCommand : String);
  54. var
  55.   sFieldName, sValue : String;
  56. begin
  57.   if (Pos(CW_Replace,sCommand) > 0) then begin
  58.     GetCommands(sCommand,sFieldName,sValue);
  59.     if not (Pos(CW_Rest,sCommand) > 0) then
  60.       FrmMenu.Table1.First;
  61.     while FrmMenu.Table1.EOF do begin
  62.       FrmMenu.Table1.Edit;
  63.       FrmMenu.Table1.FieldByName(sFieldName).AsString := sValue;
  64.       FrmMenu.Table1.Post;
  65.     end;
  66.   end;
  67. end;
  68.  
  69. procedure TFrmCommandWindow.GetCommands(sCommand,sFieldName,sValue : String);
  70. var
  71.   I : Integer;
  72.   sCommandValue : String;
  73. begin
  74. //  if Pos
  75. //  sCommandValue := s
  76. end;
  77.  
  78. end.
  79.