Home > Articles

This chapter is from the book

Application Deployment with PowerBuilder 9

There comes a point in the lifecycle of every software application in which the developer feels confident enough in the quality of the code to "release" the application for others to use. These users might be a Quality Assurance group or a Beta tester, or they might be the eventual end users. PowerBuilder developers must choose between several alternatives before the deployment process can be started. This section examines those alternatives and discusses the various factors that affect the deployment process for PowerBuilder applications.

Compiler Basics

PowerBuilder offers two different compiler formats for PB applications: interpreted Pcode (pseudocode) and machine code. There are distinct advantages and disadvantages to each format, as shown in Table 3.1.

Table 3.1 Comparison of Pcode and Machine Code Compilation

 

Advantages

Disadvantages

Pcode

Smaller file size than DLLs

Slower performance for PowerScript- intensive operations

 

Faster compile times

 

 

Portable to all supported PB platforms

 

Machine Code

Faster execution for computation-intensive operations

Larger file sizes

 

 

Slower compile times

 

 

Not portable to other execution platforms


Basically, if your primary goal is to optimize speed of execution for computation-intensive script operations, choose machine code. It will offer better performance for operations such as floating point arithmetic and looping constructs. This improved performance will come at the expense of the speed of the compile process, and the overall size of the distributed application files will increase.

For nearly all other applications, Pcode compiles should provide adequate performance, with faster compile times and smaller application file sizes. In addition, Pcode can be run on any platform that is supported by PowerBuilder's Virtual Machine (PBVM), whereas machine code applications can only run on the same platform on which they were compiled.

The Application Package

All PowerBuilder applications consist of at least one of the following items:

  • The executable file

  • Dynamic libraries

  • External resources

For client/server applications, there will always be an executable file. This file, at a minimum, contains code that enables the application to start and initiate processing. The packaging model that was chosen at compile time determines the additional content of the EXE file. The EXE file can contain one or more of the following:

  • Compiled versions of the objects from the application's libraries

  • This is the default packaging model, in which all the objects are compiled directly into one large EXE file. This increases the overall size of the EXE file, but greatly simplifies the deployment task because there's only one application file to deploy.

  • An execution library list

  • PowerBuilder provides the option to compile PBLs into dynamically linked libraries (either Pcode PBDs or machine code DLLs). This packaging model offers several benefits, which are covered in the next section.

  • External resources

  • Bitmaps, icons, cursors, and other image files can be compiled directly into the application's EXE or dynamic libraries, or delivered as separate files to be resolved at runtime.

Using Dynamic Runtime Libraries

Compiling PowerBuilder applications to dynamic runtime libraries instead of a single large EXE file offers several important benefits, and it's important to understand the differences between these two deployment options:

  • Increased Modularity

  • The application is broken up into smaller, more logically organized files rather than a single large EXE file. These dynamic libraries will carry the same name as their corresponding PBL, but will have either a .pbd (Pcode) or .dll (machine code) file extension.

  • Improved Reusability

  • It is possible for several PowerBuilder applications to share the same set of dynamic libraries. For example, a library of common report datawindows can be compiled to a single dynamic library and shared across separate applications. However, it should be noted that sharing of dynamic libraries might result in application instability. An example of this would be a PFC-based application that implements a corporate, or "PFD," set of libraries between the PFC and PFE libraries. This application could not share its PFC and PFE dynamic libraries with a second PFC-based application that did not use the same PFD layer. To ensure the overall stability of the suite in such an arrangement, each application should have its own set of dynamic libraries.

  • Reduced Complexity

  • When compiling an application into a single EXE file, PB will scan the PBL files and only copy in the objects that are specifically referenced by that application. The goal of that step is to reduce the overall size of the deployed EXE file. Consequently, objects that are only referenced dynamically will not be included in the deployed application. Typical examples of dynamic references would be

    dw_1.dataobject = "d_customer"
    • or

    CREATE n_base USING "n_cst_customer"

    In these examples, the datawindow "d_customer" and the nonvisual object "n_cst_customer" are referenced only as text strings in PowerScript and would not be automatically compiled into a deployed EXE file. However, there are techniques to work around this limitation. The compiler will find any dynamically referenced datawindow objects whose names have been listed in a PowerBuilder Resource File (PBR). PBR files are covered in more detail in the next section. However, no such facility exists for other object classes, such as the nonvisual object "n_cst_customer" listed previously. One technique is to create a "dummy" nonvisual object that has local variable declarations for all the dynamically referenced classes.

    This complexity is eliminated completely simply by using dynamic libraries. PB copies all the objects in a PBL into its corresponding PBD or DLL at compile time, so all object classes, even those that are referenced dynamically, are resolvable at runtime.

Using External Resources

In addition to PowerBuilder objects such as windows, menus, and user objects, applications can also use external resources, such as image files, bitmaps, icons, and so on. When these resources are used in an application, they must be delivered along with the PowerBuilder objects. There are several different approaches for the delivery of these external resources as well:

  • Include them in the executable file.

  • For objects that are compiled into the executable file (as opposed to dynamic libraries), PowerBuilder will automatically scan these objects looking for specific resource file references, usually found in the object's properties panel. These files will be compiled directly into the EXE file. Dynamically referenced resources and datawindows will not be detected during this scan. To build these resources into the executable file, you must create a PowerBuilder Resource (.PBR) file. This is an ASCII text file that tells the PB compiler where to find the resources that are used by the application. Listing 3.1 shows a few lines from a sample PBR file.

    Listing 3.1 Sample PBR File Listing

    peat.pbl(d_project)
    iopen.bmp
    peat.bmp 
    c:\myapp\peat.pbl(d_dddw_project)
    .\icons\deviate.ico

    Resource file references in a PBR file can be qualified with either full or relative references, or unqualified. The first line of Listing 3.1 shows an unqualified datawindow reference, and the second and third lines show unqualified bitmap file references. For these to be successfully copied into the executable, they must exist in the current directory when the compile is performed. The fourth line shows a fully qualified datawindow reference. The fifth line shows another technique, using relative path references. In this case, the .ICO file must exist in a folder named \icons that exists below the current directory. Relative path references are less restrictive than fully qualified pathnames and still allow for references to resources outside of the current directory.

    It is important to note that the path and file naming convention used in the PBR file must exactly match the reference in the script. PB will not find the resource at runtime if the references are not exactly equal. For example, the peat.bmp file referenced in Listing 3.1 will not be found at runtime if the file is referenced in PowerScript as "c:\myapp\peat.bmp".

  • Include them in dynamic libraries.

  • If the application is packaged into dynamic libraries (either PBDs or DLLs), PowerBuilder can compile the resource files into the corresponding dynamic libraries. However, the "automatic scan" that happens for objects compiled into the EXE doesn't happen, even for explicitly referenced resources. Therefore, it's necessary to build a PBR file when deploying PBDs or DLLs with external resource references. It is not, however, required to place datawindow references into the PBR file when compiling to dynamic libraries because all the objects in the PBL are copied into the corresponding PBD or DLL file.

  • Deliver them as separate files.

  • A final option is to deliver the resource files along with the compiled application code. This increases the number of files that need to be delivered, but can be beneficial when a resource file needs to be updated. If the resource is compiled into the EXE or PBD/DLL, it would be necessary to recompile and redeploy the application. If the resource files are delivered separately, it's possible to swap in a new image file without recompiling.

    It's important to note that this is the least efficient model at execution time because the PB application must search the file system for the requested resource file.

The Project Painter

The Project object encapsulates all the information required to regenerate and compile a PowerBuilder target. Project objects are maintained in the Project painter. This painter received a facelift in version 8 and is unchanged in version 9.

Open a new project by selecting File, New from any menu, and then navigating to the Project tab. If there are multiple Targets in the current Workspace, they will be shown in the Target drop-down list at the bottom of the dialog box. Select the correct Target, select the Application icon, and then click OK to open the Project painter. For a step-by-step approach to constructing the Project, select the Application Wizard icon. That presents each section of the Project painter screen in a wizard-based dialog box. Figure 3.1 shows a typical Project object in the PB 9 Project painter.

Figure 3.1Figure 3.1 Project Painter.

The following list describes the various options and choices available in the Project painter screen, shown in Figure 3.1:

  • Executable Filename: This is the name of the EXE file that will be created. If a pathname is specified (either fully qualified or relative), the EXE file will be created in that folder. If no path is specified, the EXE file will be created in the folder that contains the PBL with the Project object.

  • Resource Filename: This is the name of the PBR file that helps to resolve external resources, such as bitmaps, icons, and cursors. The proper use of PBR files will be discussed in the next section.

The following are the Project Build options:

  • Prompt for Overwrite: When this setting is on, the user will be prompted to overwrite the EXE and PBD files as they are being written.

  • Rebuild: This option offers the choice between an incremental or full rebuild during the regeneration stage of the compile. An incremental rebuild is designed to only regenerate objects that have been changed since they were last regenerated, including ancestor and descendent classes, as well as all objects referenced by those that have changed. This option can result in quicker regeneration times, but can be less reliable than a full rebuild, which regenerates all objects in the entire Target. It is recommended to always perform a full rebuild prior to releasing an application for QA testing or deploying to an end user.

The following are the Code Generation options:

  • Machine Code: Select this option to compile to machine code DLLs instead of Pcode PBDs.

  • Trace Information: For machine code compilation only. When selected, it will add debugging information into the DLLs that allow the /PBDEBUG switch to create the .DBG files for the application. This capability is built-in for PBDs, so the option is not applicable.

  • Error Context Information: For machine code compilation only. Check this on to display context information (such as object, event, and script line number) for runtime errors.

  • Optimization: For machine code compilation only. If this option is selected, PowerBuilder will apply optimizations to reduce the size of the DLL files or to increase their execution speed.

  • Library: This section lists each PBL found in the target's library list. Each PBL in the list will have the following two options available.

  • PBD/DLL: Select this option to deploy the specified PBL as either a Pcode PBD or a machine code DLL. If this option is not selected, the objects in the specified library will be compiled directly into the EXE file.

  • NOTE

    When compiling to machine code, the label of the PBD/DLL option will read "DLL."

  • Resource Filename: Use this entry to reference a specific PBR resource file for the selected library. If a .PBR file is specified here, the external resources that are referenced will be compiled into the corresponding dynamic library.

In prior releases, someone examining the File Properties for a compiled PowerBuilder application would only see "Sybase Corporation." It is now possible to stamp the compiled executable file with customized information. The settings made in this section will appear in the File Properties of the compiled executable, as shown in Figure 3.2.

Figure 3.2Figure 3.2 The File Properties dialog box.

The first four attributes are self-explanatory, and they appear in the File Properties dialog box with the same attribute name. Compare the dialog box shown in Figure 3.2 with the Project object shown in Figure 3.1.

  • Company Name

  • Product Name

  • Description

  • Copyright

The next two attributes have two separate fields, and their entries appear in different places in the File Properties dialog box. The two smaller fields on the left are a series of four comma-separated numbers, and they could be used to store the Major/Minor/Incremental/Build numbers of the application. The larger fields on the right are simple text values:

  • Product Version (left side): This number does not appear in the File Properties dialog box, but it can be seen in a tool such as Visual C++ by opening the EXE file as a resource. An installation tool, such as Microsoft's Windows Installer, can use this value to decide whether to overwrite the file during a patch process. Prior to PB 9, the only version information available in the EXE file itself referred to the version of PowerBuilder that was used to perform the compile.

  • Product Version (right side): This value appears in the Product Version file property.

  • File Version (left side): This value can be seen as the File Version property, found at the top of the File Properties dialog box. It is also seen in the ToolTip for the EXE file.

  • File Version (right side): This value also appears as the File Version property, but this is the one in the list at the bottom of the File Properties dialog box.

Target-level Deployment

Once a Target contains a Project object, it becomes possible to use the "Deploy" operation on that Target. This option appears in the System Tree context menu for the Target, and in the Entry, Target menu in the Library Painter.

The Target properties dialog box contains a tab labeled Deploy (see Figure 3.3). This tab lists all the Project objects that are found in the Target. If more than one Project exists for the Target, use this tab page to specify which Projects are to be built and in which order.

Figure 3.3Figure 3.3 The Target Properties/Deploy dialog box.

If the Target is registered to Source Control, it will first be necessary to perform a checkout on the Target before its properties can be altered.

Workspace-level Deployment

When the Workspace contains multiple Targets, and a Project object has been enabled for the Targets as outlined in the previous section, the Workspace can also be deployed with a single mouse-click. The Workspace properties dialog box contains a Targets tab that is similar in nature to the page found in the Target properties dialog box. This list shows all the Targets, and the Projects in those Targets, that have been set up for automatic deployment. Use the check marks to include or exclude Targets from automatic Workspace deployment and also to rearrange the order of their deployment within the Workspace.

The second tab in the Workspace properties dialog box is labeled Deploy Preview. The changes made in the Targets page are immediately reflected in the Deploy Preview page, so this is a way to verify the proper order of deployment before the changes are applied.

Figure 3.4 shows a side-by-side view of both the Targets and the Deploy Preview tabs of the Workspace properties dialog box. The example shown is a Workspace that contains multiple Targets, and each Target has a single Project object enabled in its corresponding Target properties dialog box.

Figure 3.4Figure 3.4 The Workspace Properties dialog box.

Building a Runtime Library

The option to recompile a single PBD has existed for several generations of PowerBuilder, and it continues to be an available option for quickly rebuilding a single library following a minor change to an object in the corresponding PBL. In PB 9, the Build Runtime Library... option exists in the System Tree context menu when the selected treeview item is a PBL, and in the Entry, Library menu item of the Library Painter. When selected, the dialog box shown in Figure 3.5 is presented. This dialog box contains a subset of the Project painter options discussed in the previous section. When this option is used, a dynamic library is created for the selected PBL. If the Machine Code option is selected, a DLL will be created; otherwise, PB will generate a Pcode PBD.

Figure 3.5Figure 3.5 The Build Runtime Library dialog box.

This feature should be used with caution because it can lead to unstable applications. For example, if a function definition in an ancestor class is altered, and only the PBL containing that class is rebuilt into a PBD, other PBLs containing descendent classes or other objects referencing that function would become invalid. This would result in runtime errors when the deployed application was executed. The proper way to compile following an object change of this nature would be to perform an incremental or full rebuild of the entire Target.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020