Editing Code in Delphi

The Code editor is a full-featured ASCII editor. If using the visual programming environment, a form is automatically displayed as part of a new project. You can start designing your application interface by placing objects on the form and modifying how they work in the Object Inspector.

But other programming tasks, such as writing event handlers for objects, must be done by typing the code. The contents of the form, all of its properties, its components, and their properties can be viewed and edited as text in the Code editor.

You can adjust the generated code in the Code editor and add more components within the editor by typing code. As you type code into the editor, the compiler is constantly scanning for changes and updating the form with the new layout. You can then go back to the form, view and test the changes you made in the editor, and continue adjusting the form from there.

The code generation and property streaming systems are completely open to inspection. The source code for everything that is included in your final executable file—all of the VCL objects, CLX objects, RTL sources, and project files—can be viewed and edited in the Code editor.

When you have finished designing your application interface on the form and writing additional code so it does what you want, you can compile the project from the IDE or from the command line. All projects have as a target a single distributable executable file.

You can view or test your application at various stages of development by compiling, building, or running it:

  • When you compile, only units that have changed since the last compile are recompiled.
  • When you build, all units in the project are compiled, regardless of whether they have changed since the last compile. This technique is useful when you are unsure of exactly which files have or have not been changed, or when you simply want to ensure that all files are current and synchronized. It's also important to build when you've changed global compiler directives to ensure that all code compiles in the proper state.You can also test the validity of your source code without attempting to compile the project.
  • When you run, you compile and then execute your application. If you modified the source code since the last compilation, the compiler recompiles those changed modules and relinks your application.

If you have grouped several projects together, you can compile or build all projects in a single project group at once. Choose Project|Compile All Projects or Project|Build All Projects with the project group selected in the Project Manager. To compile a CLX application on Linux, you need Kylix.

With the integrated debugger, you can find and fix errors in your applications. The integrated debugger lets you control program execution, monitor variable values and items in data structures, and modify data values while debugging. The integrated debugger can track down both runtime errors and logic errors.

By running to specific program locations and viewing the variable values, the functions on the call stack, and the program output, you can monitor how your program behaves and find the areas where it is not behaving as designed. The debugger is described in online Help.

You can also use exception handling to recognize, locate, and deal with errors. Exceptions are classes, like other classes in Delphi, except, by convention, they begin with an initial E rather than a T.

Delphi includes add-on tools to help with application deployment. For example, InstallShield Express (not available in all editions) helps you to create an installation package for your application that includes all of the files needed for running a distributed application.

TeamSource software (not available in all editions) is also available for tracking application updates. To deploy a CLX application on Linux, you need Kylix.