Wednesday, October 07, 2020

Completing the second version of PrioXRef

I spent several hours yesterday and today working on the Priority Procedure Cross Referencer and Fault Analyser (PrioXRef). I finished off the deceptive assignment statement (:C = (:B = 1 ? 2 : 3) initialises :C but it does not initialise :B) then continued working on other kinds of statements. I noticed that at one stage, some variables were being marked as unused after their definition, which I know is wrong. It turned out that the code that reads comments was not working correctly and caused the program to skip over a large chunk of the program. I wrote a routine that sort of works but I wasn't happy with this and tried to find a better solution. 

The problem is that two characters have to be detected in order to end a comment (*/) and my routine had great difficulty in doing so. It doesn't help that I often used long comment lines (like /****************/ to mark sections in my code: these were causing the problem. After thinking about the problem for several hours, I decided eventually to 'cheat': I used the Delphi function pos that looks for a substring in a string, making the detection of */ very easy. Thinking about it now, this is hardly 'cheating' as I am using several other Delphi constructs, but the idea was to write the lexical analyser using standard Pascal as much as possible.

Once I got past the comments, other things became clearer. I added references to ERRMSG and WRNMSG that weren't in my original plan; this was very easy to do and adds value. When I thought that I had developed the program as much as possible, it then occurred to me to display the references in a tree view instead of as multiple lines of text. This is definitely easier to read. I'm still keeping the original 'block of text' so that the references can be exported as a file. Adding the references to the tree view was fairly simple, but now looking at the screen shot, I see that an extraneous colon has been added.

For all the help that  PrioXRef can bring to the table, there are still areas that can give a programmer grief. I have just spent a frustrating hour trying to figure out why an interface procedure that I wrote several months ago had suddenly stopped working. The interface is for the SUPPLIERS screen and naturally uses fields from the eponymous table. I eventually discovered that the problem was that I was accessing the default purchase order type, a pointer to which is held in the table SUPPLIERSA. There was no record in this table for the supplier that I was testing and so my query result was empty. The rationale behind extension tables (such as SUPPLIERSA) is that one can define for this table fields that are used by only a subset of the suppliers and so save space in the database. 

I should add a heuristic to PrioXRef that tables whose name ends in A should appear in queries with a question mark (e.g. SUPPLIERSA ?), which is Priority's way of saying 'this is a left join'. This would take a fair amount of work as PrioXRef tends to ignore table names that appear in FROM clauses (which is where the question mark would appear): it's only interested in tables that have LINK statements.

PrioXRef can be downloaded here.



No comments: