What are the general debugging methods

What is a debugger for?

Home

What is a debugger for?


 

As you develop and test your methods, it is important to be able to find and fix any errors they may contain.

There are different types of errors when programming: Typing errors, syntax or process errors, structure errors or logical errors and runtime errors.

The Method editor.

They appear in red. A message appears in the area below the method window. The following window shows a highlighted typing error:

Note: The comments were added manually afterwards. 4D only changes the color where the error occurs.

Typos like this usually lead to syntax errors. The table name is unknown here. The error is described in the information area when you confirm the programming line.

In this case, correct the typing error and confirm the correction with the Enter key on the numeric keypad. Further information can be found in the manual 4D design mode.

Some errors are only found when executing the method. If there is a syntax error, the Syntax Error window is displayed. Example:

A table name was passed in this window for the Uppercase command, but the command expects an expression of the Text type. The "Details" area is expanded to show the most recent error and its number.

For example, there may not be enough memory to create an array or BLOB. Or you want to access a document on the hard drive that does not exist or has already been opened by another application.

These errors are not directly related to your programming; they occur because sometimes something is wrong. In most cases, such errors can be resolved with a debugging method that uses the ON ERR CALL command.

Such errors are generally hard to find — use the Debugger. To a certain extent, the types of errors described above - with the exception of typing errors - also fall under the heading of structural errors or logical errors. For example:

  • A syntax error occurs if you try to use a variable that has not yet been initialized.
  • A process error occurs when you try to open a document whose name is received from a subroutine that does not have the correct value in the parameter. Note that in this example, the code that breaks off may be different from the code that is causing the problem.

Structural errors or logical errors also include the following situations:

  • A data record is not updated correctly because you did not check whether the data record is locked before calling SAVE RECORD.
  • A method does not work correctly because you have not checked whether an optional parameter is present.

Errors can occur in application mode that you have never seen before in interpreted mode. Example:

This message says: "You are trying to access a character that is outside the defined length for the character string." To quickly find the cause of the problem, write down the method name and the line number, reopen the interpreted version of the structure file and go to the appropriate line in the method.

Mistakes are nothing out of the ordinary. It would be abnormal to write hundreds of lines of programming without any mistake. Finding and correcting errors is a completely normal process.

4D's multitasking capabilities allow you to edit and step through methods quickly as you can switch between windows. You don't have to go through all of the programming every time. Also the Debugger accelerates error management.

A typical early mistake is to click the Cancel button in the Syntax Errors window while troubleshooting, go back to the Method Editor, and scour the code to find what is wrong. Do not do that! You save a lot of time and energy when you always with the Debugger work.

  • If an unexpected syntax error occurs, use the Debugger.
  • If a process error occurs, use the Debugger.
  • If any other type of error occurs, use the Debugger.

In 99% of the cases the delivers Debugger the exact information needed to understand why an error occurred. You can then use this information to rectify the error.

tip: Study and experiment with that for a few hours Debugger. In this way, you can save days and weeks in the future when searching for and correcting errors.

use this Debugger also for developing code. Sure, sometimes you write a rather large amount of code. No matter how precise you are, it is only when you run it that you can be absolutely sure that your code is working. Instead of letting it run blind, put the TRACE command at the beginning of your code. You can then do it step by step and see what happens. A purist may be against this method, but sometimes pragmatism pays off. Anyway ... use that Debugger.

use this Debugger.



Interrupt commands
Debugger window
Window syntax error
ON ERR CALL
Debugger keyboard shortcuts
Interruption list

Product: 4D
Subject: Debugging

4D programming language (4D v15.4)
4D programming language (4D v15)
4D programming language (4D v15.3)
4D programming language (4D v15.5)
4D programming language (4D v15.6)