Debugging Techniques
Syntax errors are flagged in the Map Designer on the Source Connection tab when a script is connected with a source file or when a previously connected script is refreshed. To correct syntax errors, follow these steps:
• While the Map Designer is still open, open a text window and edit the script with the editor of your choice.
• Make changes to the script to correct the syntax error. Refer to the line and position indicated in the syntax error that the Map Designer has logged.
• Save the changes to the script.
• Return to the Map Designer. To have the Map Designer re-read the script, click the Refresh Script button located just under the Connect button.
• If no other syntax errors are found, the Source Data Browser and Source Record Types screens will now reflect the changes made to the script.
Trace
CXL has built-in trace functionality that allows a script to log Debug Messages into a log file while the script is executing. Error Logging must be turned on in the Map Designer with Debug Message types selected for the trace messages to be logged.
To turn logging on in the Map Designer, choose Preferences from the View Menu and select Error and Event Logging ON/OFF in the Logging Defaults tab. This will turn error logging on for all conversions. To turn it on for an individual conversion, use Conversion Properties. In these two Error Logging windows, the log file may be set along with the message types to be logged either for all conversions, or for that particular conversion. Since a CXL trace logs debug messages, this message type should be selected under Error Types to Log.
The information logged to the log file during a trace is:
• the first 32 characters of each input line
• an indication for each pattern/action statement of whether the pattern match is successful or not.
The t
race on statement should be used to turn tracing on. The
trace off statement should be used to turn tracing off. If tracing the entire document is desired, put the
trace on statement in the
BEGIN statement. For additional information on
trace functionality, see the sections
trace on and
trace off in
Language Syntax and Examples.
Comments
A useful debugging technique to use when having difficulty locating an error is to comment out successively smaller blocks of code until the statement with the error is identified.
Logmessage
Try to find a logic error by examining the script closely to identify statements that should always execute. If the error isn't obvious, place
logmessage statements at these locations so that a message will print to verify execution does occur. Place
logmessage calls between other appropriate lines in the script to verify they execute under the correct conditions. The idea is to "home in" on the non-executing statements by moving a
logmessage to different locations in the script. You may want to simplify your data file when performing these tests. For detailed information on how to use the
logmessage built-in function, see
Language Syntax and Examples.
Source Data Browser
When there is output, the Source Data Browser in the Map Designer can be used to visually verify the output data from the accept statements in the script.
Last modified date: 02/01/2024