KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the compiler to check for coding mistakes
PRODUCT: 4D Compiler | VERSION: 2004 | PLATFORM: Mac & Win
Published On: November 12, 2008

4D can be lenient with coding styles and syntax. Sometimes you may write a line of code that is missing a parenthesis, or perhaps you have used the same variable name in multiple methods with conflicting types. The compiler is a good way of checking for these types of code mistakes.

In order to make the compiler catch even more mistakes, it is suggested that you enable the "All variables are typed" compilation path in the Preferences under "Design Mode / Compiler":



To access the compiler from design mode click on the Compiler icon in the toolbar:



Or to access the compiler from design mode click on the Design drop down menu then choose Compiler from the list:




Once in the compiler, press the Compile button to check for errors. Some possible results could look like:



The developer should be able to look at the results of the compiler and fix each error listed. Double clicking on an error in the compiler will take you directly to the method and line it is referring to. After fixing the code, return to the compiler and press the Compile button again

Here is a screen shot of the same code fixed:



If after fixing your code you do not want to run your application compiled, simply click on the "Clear Compiled Code" button to remove the compiled code.

Commented by Jesse Pina on May 1, 2009 at 12:42 PM
This Tech Tip is not just applicable to 4D 2004. Using the compiler to check for coding mistakes is very useful no matter what version of 4D you are using.
Commented by Tim Penner on March 27, 2009 at 4:40 PM
In addition to the "Compile" button, the "Check Syntax" button can also be used to check for coding mistakes. If you do not want to run your database compiled, using "Check Syntax" as opposed to "Compile" will also alleviate the need to "Clear compiled code" afterward. In situations where the compiler button is grayed out (such as with 4D Standard edition) the "Check Syntax" button is the only way to do this.