home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP5WATCH.ZIP / WATCHDEM.PAS next >
Encoding:
Pascal/Delphi Source File  |  1989-03-24  |  1.9 KB  |  67 lines

  1. Program WatchDem;
  2. Uses WatchMgr;
  3.  
  4. CONST RecName: RECORD
  5.         Component1: STRING[20];
  6.         Component2: LongInt;
  7.       END  =  (
  8.         Component1: 'hello world';
  9.         Component2: 12345678
  10.       );
  11.  
  12. VAR n:WORD;
  13.  
  14. BEGIN
  15.  
  16.  {- Use ClrWatch to reset after a partial program trace -}
  17.   ClrWatch;
  18.  
  19.  {- Set some watches -}
  20.   AddWatch('WatchDem.RecName.Component1');  {- fully qualified -}
  21.   AddWatch('RecName.Component2');
  22.   Inc(RecName.Component2);
  23.  
  24.  {- Established watches may be inspected under program control -}
  25.   FOR n:=1 TO WatchCount do Writeln(n:3,' [',WatchStr(n),']');
  26.  
  27.  {- DelWatch requires a precise watch string specification -}
  28.  {- The following will not delete WatchDem.RecName.Component1 -}
  29.   DelWatch('RecName.Component1');
  30.  
  31.  {- However case and leading/trailing spaces are not significant -}
  32.  {- The following WILL delete WatchDem.RecName.Component1 -}
  33.   DelWatch('   wATCHdEM.recname.COMPONENT1    ');
  34.  
  35.  {- Clear all watches -}
  36.   ClrWatch;
  37.  
  38.  {- you can use AddWatch to display messages under program control -}
  39.   AddWatch(WatchMgr.Copyright);
  40.   ClrWatch;
  41.  
  42.  {- Display the number of command line parameters -}
  43.   n := ParamCount;
  44.   AddWatch('      n      ');
  45.  
  46.  {- Like "Break/Add watch", leading and trailing spaces are ignored -}
  47.  {- There are presently no command line parameters -}
  48.  
  49.  {- Watch an area of memory in the Program Segment Prefix -}
  50.   AddWatch('Mem[PrefixSeg:$80],27sm');
  51.  
  52.  {- Watch as a command line is patched in -}
  53.   String(Ptr(PrefixSeg,$80)^) := 'Watch Manager Version 1.0'#13;
  54.   Dec(Mem[PrefixSeg:$80]);  {- length should exclude trailing #13 -}
  55.  
  56.  
  57.  {- Recheck the number of command line parameters -}
  58.   n := ParamCount;
  59.   WRITELN('Patched Command Line Parameter: ',ParamStr(1));
  60.  
  61.  
  62.  {- The watch routines may be nested in a natural fashion -}
  63.  {- The following will delete the most recently defined watch -}
  64.   DelWatch(WatchStr(WatchCount));
  65.  
  66. END.
  67.