Opening existing project code

When reopening a modified or saved file, PowerBASIC Forms parses (scans) the file, seeking out the #PBFORMS delimited blocks. From the information given in these blocks, PowerBASIC Forms reassesses the project framework, permitting additional dialogs, controls and other features to be added to the project. As these changes are made, PowerBASIC Forms merges them into the source code file(s).

However, when merging new or changed code back into an existing file, PowerBASIC Forms only saves the information into the named blocks that exist in the project file.

This ensures that manually added code is preserved in the file. However, this also means that some changes to the project in PowerBASIC Forms may ultimately require manual editing of the project code. For example, adding (or removing) a button control from a dialog will not add (or remove) the control's %BN_CLICKED handler within the dialog callback. While this may seem cumbersome, the manual effort required for such changes is usually minor, and there are several ways to simplify this problem - we discuss these in-depth in Migrating changes.

 

Why use this strategy?

Some common visual designers maintain a list of "events" that each control offers. As controls are added and deleted, the designer automatically adds or removes the events of the control from the list of available events. While that approach can somewhat simplify the act of removing or adding controls to a window, such visual designers do not permit any editing to the actual framework that the application is built from. What is often construed as a significant convenience is often found restrictive instead - the programmer is completely prevented from making fundamental and/or radical code changes to the project framework, simply because everything is "managed" by the visual designer.

In contrast, PowerBASIC Forms offers the entire project code to the programmer. The programmer can consciously opt to forego future editing of the project within PowerBASIC Forms and is therefore completely free to edit any portion of the source code, including the code located in named blocks. Since editing code in this manner can prevent PowerBASIC Forms from opening the file again, retaining a backup copy of the original file is highly recommended.

When PowerBASIC Forms opens an existing file, it always scans the code to determine if it is a valid PowerBASIC Forms -generated file. If PowerBASIC Forms cannot identify the file, for example, if the #PBFORMS delimited blocks were edited or removed, then PowerBASIC Forms offers the option of importing the file instead. For more information, please refer to Importing code.

 

See Also

Handling new vs. existing files

Saving a project

New PowerBASIC Forms projects

Named blocks

Parent and child dialogs

Viewing the project code

Migrating changes

Importing code