fpevalw.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. {
  2. Copyright (c) 1997-2008 by the Daniel Mantione
  3. Debug expression evaluator dialog ?
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. unit fpevalw;
  11. {$H-}
  12. {****************************************************************************}
  13. interface
  14. {****************************************************************************}
  15. uses fpdebug,dialogs,views,objects,fpconst,drivers;
  16. type Pevaluate_dialog=^Tevaluate_dialog;
  17. Tevaluate_dialog=object(Tdialog)
  18. watch:Pwatch;
  19. expr_input,expr_output:Pinputline;
  20. constructor init(var bounds:Trect);
  21. procedure evaluate;
  22. procedure handleevent(var event:Tevent);virtual;
  23. destructor done;
  24. end;
  25. {****************************************************************************}
  26. implementation
  27. {****************************************************************************}
  28. constructor Tevaluate_dialog.init(var bounds:Trect);
  29. var r:Trect;
  30. l:Plabel;
  31. b:Pbutton;
  32. begin
  33. inherited init(bounds,'Evaluate expression');
  34. options:=options or ofcentered;
  35. {watch is auto initialized to nil.}
  36. r.assign(2,3,size.x-20,4);
  37. new(expr_input,init(r,255));
  38. insert(expr_input);
  39. r.assign(size.x-20,3,size.x-18,4);
  40. insert(new(Phistory,init(r,expr_input,hidEvaluate)));
  41. r.assign(2,2,size.x-20,3);
  42. new(l,init(r,'E~x~pression:',expr_input));
  43. insert(l);
  44. r.assign(2,6,size.x-20,7);
  45. new(expr_output,init(r,255));
  46. insert(expr_output);
  47. r.assign(2,5,size.x-20,6);
  48. new(l,init(r,'~R~esult:',expr_output));
  49. insert(l);
  50. r.assign(size.x-14,3,size.x-3,5);
  51. new(b,init(r,'~E~valuate',cmEvaluate,bfDefault));
  52. insert(b);
  53. //r.assign(size.x-14,6,size.x-3,8);
  54. //new(b,init(r,'Help',cmHelp,bfNormal));
  55. //insert(b);
  56. expr_input^.select;
  57. end;
  58. procedure Tevaluate_dialog.evaluate;
  59. begin
  60. if watch<>nil then
  61. dispose(watch,done);
  62. new(watch,init(expr_input^.data^));
  63. expr_output^.data^:=strpas(watch^.current_value);
  64. expr_output^.drawview;
  65. end;
  66. procedure Tevaluate_dialog.handleevent(var event:Tevent);
  67. begin
  68. inherited handleevent(event);
  69. if event.what=evCommand then
  70. case event.command of
  71. cmEvaluate:
  72. evaluate;
  73. end;
  74. end;
  75. destructor Tevaluate_dialog.done;
  76. begin
  77. if watch<>nil then
  78. dispose(watch,done);
  79. end;
  80. end.