Fancy ZSTEP GTM

From VistApedia
Revision as of 17:18, 28 January 2019 by Shabiel (talk | contribs) (Created page with "General procedure: # Put a breakpoint on the code you want to debug: ZB UPDATE^DIE # Set special ZSTEP # Execute the code you want to debug: S FDA(3.1,"?+1,",.01)="BOO" D UPDA...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

General procedure:

  1. Put a breakpoint on the code you want to debug: ZB UPDATE^DIE
  2. Set special ZSTEP
  3. Execute the code you want to debug: S FDA(3.1,"?+1,",.01)="BOO" D UPDATE^DIE(,$NA(FDA))
  4. Once you hit the breakpoint, type ZSTEP INTO to activate stepping. The entire routine execution will be shown.


Regular ZSTEP (save dev and restore dev after each line)

n oldio s oldio=$i u 0 w $t(@$zpos),! b  u oldio

Detect if a variable has changed (in this case, $data of DIC(0)):

b:($g(olddic)'=$d(DIC(0)))  s olddic=$d(DIC(0)) zstep into

Print source code while executing

S $ZSTEP="W $ZPOS,?20,$T(@$ZPOS),! ZSTEP INTO"

You can combine these together, for example, to print all executed lines and stop when a variable changes. Here's how I did that:

n oldio s oldio=$i u 0 b:($g(olddic)'=$d(DIC(0)))  s olddic=$d(DIC(0)) zp @$zpos u oldio zstep into