Wednesday, 30 September 2020

Using the cross referencer in the wild

So far, I've been using the cross referencer to check programs that have been debugged. Even so, I am finding problems here and there, primarily forgetting to unlink tables.

This morning I wrote a new procedure that updates bills of materials; the details aren't particularly important. Before running it "in the wild", I ran the code through the cross referencer and received the following analysis (to my chagrin): :ANAME [Variable]:  used before initialised; used only once. This is exactly the sort of problem that the program is supposed to find. I then look in the references section for this variable and discover that its sole reference is on line 44. I then look in the code window and find this snippet

37: :FANAME = ''; 38: SELECT ACT.ACTNAME INTO :FANAME 39: FROM PARTARC, ACT 40: WHERE PARTARC.ACT = ACT.ACT 41: AND PARTARC.PART = :FMP 42: AND PARTARC.SON = :SMP; 43: LOOP 100 WHERE :ORIGNAME = :ANAME; /* no change, so skip */
Apart from the fact that :ANAME is referenced in line 43 and not 44, the error is obvious: the code finds a value and saves it in :FANAME, but the rest of the code blithely uses :ANAME. ERROR!!

Actually, in this program that's not too bad an error and will cause lines in the bill of materials to be updated unnecessarily, but that's not the point.


No comments:

Post a Comment