Writing X3 code? Let's check for errors!

Today I want to take a quick look at a function that is useful for development, Source Verification.  This tool can be useful to check for common programming errors and anomalies that could outright stop the code from working or could lead to other issues when it is executed.  Depending on the settings chosen when running the function, it can check calls to sub-programs (existence, number and coherence of setups, etc.…), control of the classes [F] and [M] (mainly to control the existence of tables, screens, and fields being used), or various other controls (instructions that have no end, ends found in a For loop, etc.…).  Let’s look at a quick example.  First, we’ll go to Development, Utilities, Verifications, Source Verification (AVERIFSRC):

Through the options available, we can search all source files within a folder, or narrow to a specific source (as well as the aforementioned controls to search subprograms and functions, classes [F] and [M], or others).  In this case, we’ll choose all the controls and point to the SPEPOH source file, then press OK:

Once the function completes, we’re provided with a log of any errors or anomalies that are found.

From this log, we can see that we have 2 errors, an If instruction with no Endif on Line 19, and a table variable that doesn’t exist on Line 15.  Let’s take a quick look at our SPEPOH source file and correct our errors:

Before our fixes:


After our fixes:

Running our source verification again, we can now see that the errors have been resolved.

Many of the issues caught through this function may be identified while using your IDE of choice to write the code or may throw an error when attempting to compile the code.  But this tool remains useful, as it gives you another tool to put in your developer’s bag of tricks.  For more information on all the various errors and anomalies that the tool is checking, please refer to the online help.  Hopefully, this tool proves to be useful for you in your future developments.  Until next time!