Elusive breakpoint

bob_upbob_up Member Posts: 155
I set a breakpoint using the code editor. The breakpoint is on a line of code following an 'IF ... THEN' statement as follows :

IF ("Item No." = 'XYZ') and ("Lot No." = 'ABC') THEN
BEGIN
MESSAGE("Item No.");
END;

The breakpoint is on the line
MESSAGE("Item No.");

I set the debugger to 'Active' but not 'Breakpoint on triggers'. When I run my application it stops on a line of code a few lines further on from where I set my breakpoint. If I try and remove the 'new' breakpoint in the debugger and replace it on the line of code I want it on, the editor beeps and refuses to let me do it, like it isnt a valid line of code.

It is as if the code, the breakpoints and the debugger are out of synch. in some way. Is there some way to resolve this ?

Answers

  • matttraxmatttrax Member Posts: 2,309
    I always set it a few lines before I want it to stop and F8 until I get to where I want to be. Annoying, but that's NAV. Maybe there's a better way neither of us know about.
  • bob_upbob_up Member Posts: 155
    That sounds wise, except I want to only stop if a certain condition is met. This is a big update process and I want to look at a specific record which is causing a problem.

    I have resolved this now by changing the code to

    IF ("Item No." = 'XYZ') and ("Lot No." = 'ABC') THEN
    BEGIN
    MESSAGE("Item No.");
    MESSAGE("Item No.");
    MESSAGE("Item No.");
    END;

    and setting a breakpoint on each of the lines which say
    MESSAGE("Item No.");

    I just wondered if there was a proper solution.
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    You've set breakpoint in the right place, on the line with MESSAGE function, not on the one with IF ... THEN.

    Sometimes the problem with displaying breakpoint dot in wrong line is caused by commented lines of code somewhere above. Try to Remove them and see if the breakpoint works as expected. Another example is when you use construction like
    IF .... THEN MESSAGE(...)
    
    (two C/AL statements on the same line - which is actually your case) instead of
    IF .... THEN 
      MESSAGE(...)
    
    I would suggest workaround like that:
    IF ("Item No." = 'XYZ') THEN
      IF ("Lot No." = 'ABC') THEN
        MESSAGE("Item No.");
    
    and setting breakpoint on the line with MESSAGE("Item No.");

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • bob_upbob_up Member Posts: 155
    Thank you Slawek. I think I can call this [SOLVED] now, although I realise these are just workarounds ...

    I cant afford to spend any more time looking for a more satisfying solution.

    :D
  • garakgarak Member Posts: 3,263
    only a tip:

    sometimes when you set a breakpoint on debugger or in the Code editor a message is dispayed: "Breakpoint still exists" (or so).
    All Breakpoints are stored in the table Breakpoint. To see the values of this table, you can create a form on this table.

    regards
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,305
    Rewrite the code like this:
    IF ("Item No." = 'XYZ') and ("Lot No." = 'ABC') THEN BEGIN
        MESSAGE("Item No.");
    END;
    
    Run the debugger with 'breakpoint on triggers' turned on. When you get to this piece of code, put your cursor on the line you need and hit F9. If a breakpoint marker appears, you'll know that it is a good point to set one. If it then doesn't stop when you want, set it one line down. It will take just a minute to figure out where to set it.

    It's annoying, but eventually you will find the right line to set the breakpoint. It's just the way that it is, sometimes the breakpoint does not align exactly with the code. It has been like that at least since version 2.01 when I started working with Navision.
Sign In or Register to comment.