Statement is false, but it get executed like true

BlankNameBlankName Posts: 20Member
edited 2019-02-06 in NAV Three Tier
I want to check last prod. order no. vs current and if they are different input it into temp table. And statement in attached photo is false, but somehow it gets interpreted as true, when both prod.order no. are same. Why this is happening?
f3mfvhpk41b2.png

Best Answer

  • BlankNameBlankName Posts: 20
    edited 2019-02-27 Accepted Answer
    AlexDen is right... Compiler caches and shows last value assigned to the variable, that's why statement was true.

Answers

  • AlexDenAlexDen Posts: 39Member
    Hi,

    You check only first record.
    You have to move this check into the loop:
    IF TRH.FINDSET THEN
      REPEAT
        IF TRH."Production Order No." <> LastEntry THEN BEGIN
        ...
        END;
      UNTIL TRH.NEXT = 0;
    
  • BlankNameBlankName Posts: 20Member
    There is 2 loops and when it gets out of first loop I want to make that check in debugger window at right you can see those two variables being the same. And I get error when it tries to write to my temp table because record already exist and my statement lastentry <> prod order no. was accepted as true when in reality they are both same and it shouldn't be true.
  • AlexDenAlexDen Posts: 39Member
    Yes, I see.

    Your code will not work if there will be records like this:
    Order 1
    Order 2
    Order 1 // Last Entry = Order 2, bit Order 1 is already saved in temp table and you will get an error.


  • BlankNameBlankName Posts: 20Member
    edited 2019-02-27 Accepted Answer
    AlexDen is right... Compiler caches and shows last value assigned to the variable, that's why statement was true.
Sign In or Register to comment.