The biggest difference between a workspace and a solution is their approach to source code management and structure.
In the Workspace format, the source code and Pcode for multiple objects are stored in the same PBL file.
In the Solution format, the PBL file is converted to a folder structure, with each folder containing source code files for multiple objects.
-
The original .pbl file is converted into a folder with the same name. The folder stores the source code for each object (such as .sr* files). This structure is similar to the folder and project structure in modern development environments, where each object has its own representation in the file system.
-
The source code for each object is stored as a separate file. Each PowerBuilder object (such as window, user object, datawindow, etc.) is split into individual source code files, which are stored in text format (usually .sr* files). Each file corresponds to a specific PowerBuilder object and contains its source code. For example, a window object named w_main would have a corresponding w_main.srw (window source code file), instead of storing all object source codes in a single large PBL file.
-
Pcode is stored in a separate directory. The compiled Pcode for each object is stored as a binary file and is kept in its own directory (typically under ".pb" and "build" directories) separate from the source code files.
This approach makes the management of source code and Pcode more independent, allowing the source code to be tracked and updated separately in version control systems, while the Pcode is only generated and stored during the build process and does not need to be managed.
The ".pb" folder is used to store intermediate files generated during the compilation process, such as Abstract Syntax Trees (AST) and intermediate Pcode files. During incremental build and save operations, the .pb folder updates only the files that have changed. However, during a full build, the .pb folder is completely regenerated.
All Pcode files are stored in the .pb/xxx/obj directory, which is used for compiling the final Pcode, and the AST files are stored in the .pb/xxx/ast directory.
The "build" folder stores the final Pcode files. The final Pcode files will be loaded when the user edits or runs the object or opens the Browser window in the IDE.
These two folders will be automatically ignored when the solution is added to Git/SVN in IDE.
In the solution format, it is unsupported to import objects into the PBL folder via ORCA.
To add a file/object to the PBL folder, you must right-click on the PBL folder in the System Tree and use the "Import From Library" option.
Or add the source file such as a .sr* file (which represents the PowerBuilder object) directly to the PBL folder. The object will be shown in the System Tree when PowerBuilder IDE is re-opened.
If you want to reorganize the PBL folders, for example, moving PBL folders into a new folder called "src_new", make sure the path changes are reflected correctly in both the .pbproj and .pbsln files.
There are two recommended approaches for changing the PBL folder structure:
-
#1: Place the .pbsln, .pbproj, and main PBL folders in one directory, and other PBL folders in the "src_new" subdirectory. Update the paths in the .pbproj and .pbsln files accordingly.
-
#2: Place the .pbsln in one directory, and the .pbproj, main PBLs, and other PBL folders inside the "src_new" subdirectory. Then, update the paths in the .pbsln file.
There are some general guidelines for the project structure:
-
Keep the .pbproj file in the same directory as the application's PBL folders: The .pbproj file should be in the same folder as the PBL folders to avoid issues with resolving paths and managing objects.
-
Use relative paths for images: The path to the image (such as the application icon) should be relative to the location of the .pbproj fie, not the root directory or elsewhere in the project structure.
-
Check the other folder structures: Ensure that the "build" and ".pb" folders are in the same location as the .pbproj file to avoid issues.
In the solution format, multiple projects can share the same PBL folder, similar to how PBL files are shared in the workspace format. And changes (such as adding or deleting objects) in one project will be synchronized to the other projects.
However, the best practice is to separate the PBL folder for each project, or generate and reference PBD in the projects.
In the solution format, referencing PBD (PowerBuilder Dynamic Libraries) is supported. To do this, open the Project Properties page, select "Convert & Add," and choose the option to add a PB Dynamic Library (*.pbd). This allows users to include PBD files in their solution, similar to how they were used in the workspace format.
Note
Referencing PBL file (as an external file) is also supported in the solution format.
Due to the change from PBL file to PBL folder in the solution format, some functions will behave differently.
Function |
Workspace |
Solution |
||||
If runs from IDE |
If runs as EXE |
1) If runs from IDE; 2) Works against external PBL file |
1) If runs as EXE; 2) Works against external PBL file |
1) If runs from IDE; 2) Works against PBL folder |
1) If runs as EXE; 2) Works against PBL folder (This is rare scenario because no one would deploy PBL folders to the client) |
|
AddToLibraryList |
No |
Yes |
No |
Yes |
No |
Yes |
GetLibraryList |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
SetLibraryList |
No |
Yes |
No |
Yes |
No |
Yes |
FindClassDefinition |
Yes |
Yes |
Yes |
Yes |
Yes |
No |
FindFunctionDefinition |
Yes |
Yes |
Yes |
Yes |
Yes |
No |
FindTypeDefinition |
Yes |
Yes |
Yes |
Yes |
Yes |
No |
LibraryCreate |
Yes |
Yes |
Yes |
Yes |
Yes (creates a PBL file not folder) |
Yes (creates a PBL file not folder) |
LibraryDelete |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
LibraryDirectory |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
LibraryDirectoryEx |
||||||
LibraryExport |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
LibraryImport |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Unsupported: FindGroup, FindClass, FindMatchingFunction, CreateSession, and RunApplication
You can use the system function IsRunningAsSolution
to implement conditional logic depending on whether the
application is running as a solution or workspace. For example, if
certain functions are only applicable in one format, you can write
code to handle the differences appropriately.
The source files generated during migration to the solution and the .pbsln/.pbproj/.pblmeta files are encoded using UTF-8 instead of the Unicode 16LE encoding. UTF-8 was chosen because the compiler only supports this encoding format and it is more space-efficient.
You can use the Import/Export option to transfer source files between UTF-8 and Unicode 16LE encodings.
You can specify whether UTF-8 includes BOM or not in the PB.INI file:
[library] DefaultEncoding=64 // 4 (default) indicates UTF-8 with BOM, 64 indicates UTF-8 without BOM, other values will be processed as 4.