Tech Articles


How to create an application from object source code files using PowerBuilder


PowerBuilder can create an entire application from the object source files stored in a source code control system without relying on existing PBLs. This has been public knowledge for years, but since I cannot find the article anymore where I read about this for the first time, and since I still see people saying the opposite, I decided to put together this short how-to guide hoping that this information will become searchable.

If someone knows the link to the original article, I will be happy to include it here or even replace this article with the link.

Used tools

If I remember correctly, I used to use this method with the MKS source code control system and PB version 9 or 10. Later, we switched to Subversion, and I have been using it with PBSCC Proxy and PB versions 10, 12.5, 2017, and 2019.

I do not remember what source code control system was used in the original article. Most likely, it was either Subversion or Git, but the proxy was different, probably PushOK. I will use PB 2019 with Subversion and PBSCC Proxy in this guide, but I do not think this method works only with these tools.

Used application

To demo the method, I will be using the PowerBuilder Examples application that is a part of the standard PowerBuilder installation. To make a few points clearer, I slightly changed the folder structure of the target by creating separate folders for each PBL. Also, I copied the target file and other binaries such as pictures to the folder that contains the application. As a result, this is what it looks like in Subversion:

Note, that PBLs are not added to source control: only the object source code (export) files are.

Prerequisites

To create PBL files, PowerBuilder needs to know which objects belong to which library and the names of the PBLs. As you may know, this information is stored in the PBG files named after the PBL files. It is imperative to have correctly formed PBG files along with the object source files under source control.

Starting point (Step 0)

All PowerBuilder needs to know to retrieve and recreate a target from source control is the name of the application object, the name of the PBL file with its relative path where the application is stored, and the name of the target file with its relative path.

To find the name of the application you need to look for a file with the SRA extension, and the name of the corresponding PBG file gives you the name of the PBL. So, in our example, the application name is "examples", the PBL is "pbexamfe\pbexamfe.pbl", and the name of the target is "pbexamfe\pb examples.pbt":

I probably do not need to mention this, because if you are working with Subversion and any SCC proxy you know this, but you will need to create a working copy of your project folder that is under source control. To do that, you need to check out the folder using TortoiseSVN or the SVN command line tool. Other source code control systems may not require this.

Step 1: Create workspace

In PB IDE, click "File", "New", and select "Workspace" in the Workspace tab page. Select a folder where you want to store your project. I created a folder as shown below:

Step 2: Create target

Click "File", "New", and select "Application" in the Target tab page. In the opened window, enter the three bits of information you found out about your application earlier. For our example, it looks as follows (I explicitly created a folder "pbexamfe" under "pbe_article"):

After clicking Finish, I have the following:

Step 3: Connect to Source Control

Right-click the workspace item in the System Tree and select "Properties". Switch to the Source Control tab page. Select your Source Control System and the project folder. In my case, it looks as follows (I selected as "Project" the working copy folder where I checked out the "trunk" folder to):

Click OK and confirm connecting to Source Control.

Step 4: Get target from Source Control

After connecting to Source Control, PB shows that your target and application object are out of sync:

Right-click your target in the System Tree and select "Get Latest Version". In the opened window, select "Perform operation on this one target file only" and click OK:

As a result, PB creates all the empty PBLs it needs for your target:

Step 5: Get all objects

Right-click your target in the System Tree and select "Get Latest Version". This time, select "Select multiple files contained in this target" in the opened window, and click OK:

The next window contains the list of all objects of your target. Make sure they are all selected with tick marks and click OK.

As a result, PB will get all the object source code files from Source Control and import them into the PBLs. Sometimes, it fails to compile all objects right away, so the following question is displayed:

Click OK and then perform Full Build of your target (you may examine compilation errors to make sure they are incorrect). After that, you have your target fully re-created from Source Control.

Step 6 (optional): Copy resources

If your application uses resource such as picture files and they are expected to be found in the application root folder, you will need to copy them manually to the corresponding folder in your workspace folder structure.

Known issues

Apart from having to Full Build the target after getting some (not all) applications from Source Control, the only issue I have come across during years and years of using this method is that sometimes PB creates incomplete target files. You should examine your target file and make sure that the @begin Projects...@end; section is present there:

Even if your target does not yet have projects, this section is needed. Otherwise, PowerBuilder will fail to get the application from Source Control. If this section is missing in your file, add an empty one.

Conclusion

If you need to rely on PBLs taken from some other place when downloading your application source code from Source Control, it means that your application is not fully under Source Control. Luckily, PowerBuilder lets you recreate you target without fiddling with PBLs. One can only wonder why Appeon decided to store PBLs along with the source files in Source Control in their native SVN interface implementation if PowerBuilder itself is capable of their creation.

 

 

Comments (2)
Tuesday, Mar 21 2023

Do you know whether this can be done with SourceSafe too?

0
Tuesday, Mar 21 2023

I never used SourceSafe, sorry. I guess the best way for you to find out is to try.

0

Find Articles by Tag

.NET Assembly Source Control SQL Server Encoding Debug PostgreSQL Sort Outlook Class Import Elevate Conference JSON Windows 10 Icons UI Mobile iOS OAuth 2.0 BLOB Icon Transaction PBVM Application DataType Debugging Menu SOAP Import JSON REST Export MessageBox Repository PowerServer Web RESTClient PBDOM Installation WinAPI Git Design Trial Linux OS Graph Export JSON SnapDevelop Resize TreeView Database RibbonBar Builder PowerServer Mobile RichTextEdit Control DevOps COM ActiveX SQL Interface Data InfoMaker Database Table SDK UI Themes Database Table Schema Bug CI/CD DataWindow JSON License PDF PBNI Open Source Configuration Authorization API PowerBuilder (Appeon) NativePDF External Functions Source Code PDFlib PowerScript (PS) C# TLS/SSL DataWindow TFS Visual Studio Oracle .NET DataStore DLL Platform Stored Procedure Model Database Painter SVN Messagging Charts UI Modernization SqlExecutor ODBC XML Excel CrypterObject Database Object Array Database Profile JSONParser Branch & Merge OrcaScript IDE Authentication Testing Event Debugger Service SqlModelMapper DragDrop PowerBuilder Encryption SnapObjects Validation PostgreSQL ODBC driver Variable 32-bit RibbonBar Performance CoderObject JSONGenerator Database Table Data File Database Connection Android Expression TortoiseGit Deployment Web API 64-bit PowerBuilder Compiler Script Filter PFC Error Event Handling Windows OS OAuth Azure Migration Syntax Web Service Proxy Jenkins .NET Std Framework HTTPClient Automated Testing WebBrowser GhostScript Text OLE Window Event Handler