fpevalw.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. {****************************************************************************}
  12. interface
  13. {****************************************************************************}
  14. uses fpdebug,dialogs,views,objects,fpconst,drivers;
  15. type Pevaluate_dialog=^Tevaluate_dialog;
  16. Tevaluate_dialog=object(Tdialog)
  17. watch:Pwatch;
  18. expr_input,expr_output:Pinputline;
  19. constructor init(var bounds:Trect);
  20. procedure evaluate;
  21. procedure handleevent(var event:Tevent);virtual;
  22. destructor done;
  23. end;
  24. {****************************************************************************}
  25. implementation
  26. {****************************************************************************}
  27. constructor Tevaluate_dialog.init(var bounds:Trect);
  28. var r:Trect;
  29. l:Plabel;
  30. b:Pbutton;
  31. begin
  32. inherited init(bounds,'Evaluate expression');
  33. options:=options or ofcentered;
  34. {watch is auto initialized to nil.}
  35. r.assign(2,3,size.x-20,4);
  36. new(expr_input,init(r,255));
  37. insert(expr_input);
  38. r.assign(size.x-20,3,size.x-18,4);
  39. insert(new(Phistory,init(r,expr_input,hidEvaluate)));
  40. r.assign(2,2,size.x-20,3);
  41. new(l,init(r,'E~x~pression:',expr_input));
  42. insert(l);
  43. r.assign(2,6,size.x-20,7);
  44. new(expr_output,init(r,255));
  45. insert(expr_output);
  46. r.assign(2,5,size.x-20,6);
  47. new(l,init(r,'~R~esult:',expr_output));
  48. insert(l);
  49. r.assign(size.x-14,3,size.x-3,5);
  50. new(b,init(r,'~E~valuate',cmEvaluate,bfDefault));
  51. insert(b);
  52. //r.assign(size.x-14,6,size.x-3,8);
  53. //new(b,init(r,'Help',cmHelp,bfNormal));
  54. //insert(b);
  55. expr_input^.select;
  56. end;
  57. procedure Tevaluate_dialog.evaluate;
  58. begin
  59. if watch<>nil then
  60. dispose(watch,done);
  61. new(watch,init(expr_input^.data^));
  62. expr_output^.data^:=strpas(watch^.current_value);
  63. expr_output^.drawview;
  64. end;
  65. procedure Tevaluate_dialog.handleevent(var event:Tevent);
  66. begin
  67. inherited handleevent(event);
  68. if event.what=evCommand then
  69. case event.command of
  70. cmEvaluate:
  71. evaluate;
  72. end;
  73. end;
  74. destructor Tevaluate_dialog.done;
  75. begin
  76. if watch<>nil then
  77. dispose(watch,done);
  78. end;
  79. end.