PowerBASIC Forms supports two methods of importing: importing from files, and importing from the clipboard.
A source code file may be explicitly imported into PowerBASIC Forms, or implicitly imported when opening a file not recognized by PowerBASIC Forms.
When PowerBASIC Forms opens an existing file, it first scans the code to determine if it is a valid PowerBASIC Forms-generated file. If PowerBASIC Forms cannot identify the file as its own creation, for example, the #PBFORMS-delimited blocks were edited or removed, PowerBASIC Forms offers the option of importing the file instead.
Importing means that the source code is read from the file and parsed accordingly, but the file name is not retained. This is similar to creating a new file - when saving the file, a new file name must be specified.
The implicit import method allows the programmer to create dialogs for the existing code, and then manually integrate the existing code into the fresh code template generated and inserted by PowerBASIC Forms. This method can also help repair damaged PowerBASIC Forms generated code.
Before any file is imported, the current project (if any) is closed. If the project in memory contained unsaved changes, PowerBASIC Forms first prompts to save them before continuing with the import.
PowerBASIC Forms then creates a new code template in memory, opens the import file, and parses it. If it finds any #PBFORMS blocks, the code from those is merged automatically into the template in memory. If the file was implicitly imported via the File | Open option, the original source code is placed at the end of the memory template, and headed with a #PBFORMS COPY marker. For explicitly imported files, any remaining code is excluded from the template in memory.
When parsing numeric equate definitions from non-PowerBASIC Forms generated source code files, the final PowerBASIC Forms generated code may need additional manual refinement of equate definitions. Essentially, PowerBASIC Forms expects all numeric equate arguments to contain only numeric literals, such as %ID_HIDE = 101.
If PowerBASIC Forms encounters an expression in the equate argument, PowerBASIC Forms will retain the first numeric literal in the line, and ignore the remainder. If no numeric literal is found, PowerBASIC Forms assigns zero. For example, %WM_TRAYICON = %WM_USER + 400 will be converted to %WM_TRAYICON = 400, and %ID_CLOSE = %IDCANCEL will become %ID_CLOSE = 0.
If a control size or location parameter cannot be resolved, PowerBASIC Forms assigns the value 10. This ensures controls are at least visible on the work dialog and can be selected by the mouse, even if none of the parameters could be determined from the original code.
The PowerBASIC Forms import facility can also import Visual Basic form (.FRM) files, along with standard resource (.RC) files. Since Visual Basic only supports one form per .FRM file, several can be imported into PowerBASIC Forms to produce one combined file. This is achieved by importing from the clipboard.
Importing from the clipboard differs from importing from files in that the current project is not closed before the import operation commences. This provides a powerful way to combine projects or translate a set of Visual Basic form files into one PowerBASIC Forms project, simply by importing each file in turn through the clipboard.
The actual operation of the Import from Clipboard dialog is very straightforward:
The Clipboard Data window displays the clipboard content purely for informational purposes. To import the content of the clipboard, simply choose the File Format that suits the type of data in the clipboard (DDT, RC, or VB Form), and click the Import button (or press Enter or ALT+I).