LESSON 11 Preparing the Application for Deployment

In this lesson you create an executable version of the application for distribution to users. Users can run this executable version of the application just as they can any other application.

You:

How long does it take?

About 10 minutes.

Create the Project object

Where you are

> Create the Project object

Create the executable file

Create a shortcut

Test the executable file

Now you create the PBTUTOR Project object. You can then use the Project object to create the executable file for the application.

About machine code

When you deploy an application to users, you may want to take advantage of the execution speed of machine code for some computations, such as loops, floating point or integer arithmetic, and function calls. While you are developing the application, you usually use Pcode because it is faster to generate.

About dynamic libraries

You can also create dynamic libraries for your application. Dynamic libraries can be used to store the objects in the application. By using dynamic libraries, you can break the application into smaller units that are easier to manage and also reduce the size of the executable file.

For small applications like the one that you are working on now, you do not need to use dynamic libraries.

  1. Click the New button in the PowerBar.

    Click the Project tab in the New dialog box.

  2. Select the Application Wizard icon and click OK.

    Using the Project painter

    If you clicked the Application icon on the Project page instead of the Application Wizard icon, you open the Project painter. You can make the same selections in the Project painter that you make with the wizard, but the wizard prompts you for this information.

  3. Click Next.

    The Specify Destination Library page displays.

  4. Select pbtutor.pbl in the Application Libraries list box if it is not already selected.

    Click Next until the Specify Build Options page displays.

    The wizard will generate a project with the following default selections:

    Wizard property

    Default value

    Project name

    p_pbtutor_exe

    Executable filename

    pbtutor.exe

    Optional resource file

    none


  5. Select Incremental Build for the Build Option.

    Click Next until the Specify Version Information page displays.

    The wizard will generate a project with the following default selections:

    Wizard property

    Default value

    Generate machine code

    No

    Build dynamic libraries

    No


  6. If you want to, enter your own version information on the Specify Version Information page.

    If you do not change the information on this page, the defaults display in Windows Explorer when you look at the properties of the executable.

  7. Click Next.

    Review the information on the Ready to Create Application page.

  8. Click the Finish button.

    PowerBuilder creates a Project object for your application and displays it in the Project painter workspace.

    After a project is defined, you can easily create an executable version of the application. Using a project saves time when you are working on an application that includes dynamic libraries that you expect to rebuild often. Selecting incremental build means that if you make a few changes, you can rebuild your project quickly, rebuilding only files that have changed or files that depend on files that have changed.

Create the executable file

Where you are

Create the Project object

> Create the executable file

Create a shortcut

Test the executable file

Now you create the executable file for your application. The executable file you generate contains definitions for all the objects in the application. For the tutorial application, this includes the bitmap file used in the login window, since you did not include a separate resource file with your project.

You can create the executable in the Project painter, but usually, once you have defined the project, you do not need to open the painter again.

Workspaces and targets in the System Tree have Incremental Build, Full Build, and Deploy items on their pop-up menus that enable you to build and deploy some or all of the projects in a target or in the whole workspace. Incremental Build and Full Build compile your code. Deploy compiles the code and, for applications like the one you built in this tutorial, creates an executable file and optional dynamic libraries.

In this lesson you look at the property sheets where build and deploy options are specified and then create the executable from the PowerBar.

  1. Close the Project painter.

    Click Yes if prompted to save changes.

  2. Right-click the pbtutor target in the System Tree.

    Select Properties and then select the Deploy tab.

    This page shows all the projects in this target (currently only one).

    If you have more than one project in the target, you can change the order in which they are executed and select which projects you want to build.

  3. Leaving p_pbtutor_exe checked, click the Cancel button.

  4. Right-click MyWorkspace in the System Tree.

  5. Select Properties and select the Deploy Preview tab.

    The Deploy Preview page shows all the targets in your workspace and the projects in each that have been selected for deployment, in the order in which they are to be deployed. You cannot change anything on this page -- you use it to check that you have set up deployment options for your workspace the way you want to. All the projects shown on this page are deployed when you click the Deploy button in the PowerBar.

    This workspace has only one target and only one project, so you can use the Deploy button to create the executable.

  6. Click the Cancel button to close the property sheet.

  7. Click the Deploy button () in the PowerBar.

    The process of creating the executable file might take a few moments. While PowerBuilder is working, you can look at the Output window at the bottom of the screen to see what PowerBuilder is doing.

    If you wanted to stop the deployment process, you could click the Stop button in the PowerBar. When deployment is complete, the Output window displays the following text: Finished Deploy of workspace MyWorkspace.

Create a shortcut

Where you are

Create the Project object

Create the executable file

> Create a shortcut

Test the executable file

Now you create a shortcut for the executable file. The icon serves as a shortcut to open the executable file. You can add the shortcut directly to the desktop or to the program group of your choosing.

  1. Minimize PowerBuilder.

    PowerBuilder is minimized to an icon on the taskbar.

  2. Right-click on a blank area of the desktop.

    Select New>Shortcut from the pop-up menu.

  3. In the Create Shortcut dialog box, click the Browse button and locate pbtutor.exe.

    If you accepted the default installation locations, the file is in %SystemDrive%\Users\[username]\Documents\Appeon\PowerBuilder [version]\Tutorial.

  4. Click OK, then click Next.

  5. Type SportsWear, Inc. as the name of the shortcut.

  6. Click Finish to create the shortcut on the desktop.

    Now you must modify a property of the shortcut so that you can run the application. You can also change the icon.

  7. Right-click the SportsWear, Inc. icon on the desktop.

    Choose Properties in the pop-up menu.

  8. Select the Shortcut tab.

    Type the path to the PowerBuilder shared modules in the Start In box.

    Click OK.

About the location of the shared modules

When you install PowerBuilder Runtime, the installation process puts the DLLs in the %AppeonInstallPath%\Common\PowerBuilder\Runtime [version] directory. The default location is: C:\Program Files\Appeon\Common\PowerBuilder\Runtime [version] (for 32-bit DLLs) and C:\Program Files\Appeon\Common\PowerBuilder\Runtime [version]\x64 (for 64-bit DLLs).

If you want the user to be able to run the application by double-clicking the executable file, you must include this runtime directory in the system environment path.

Test the executable file

Where you are

Create the Project object

Create the executable file

Create a shortcut

> Test the executable file

Now you test the new executable file.

  1. Make sure the pbtutor.ini file is in the same directory as the pbtutor.exe executable file.

    The default location of the pbtutor.ini file and the pbtutor.exe file is %SystemDrive%\Users\[username]\Documents\Appeon\PowerBuilder [version]\Tutorial.

  2. Double-click the icon for the tutorial application.

    The application begins running.

  3. Test the application.

    Notice the changes you made to the customer information.

  4. When you have finished testing the application, select File>Exit from the menu bar.

What to do next

Congratulations. You have completed the client-server part of the tutorial. Now you know the basics of application development with PowerBuilder.

The Preface to this book includes a guide to the PowerBuilder documentation. To further your education, you should continue with these books:

Users Guide
Application Techniques
DataWindow Programmers Guide

All the PowerBuilder books are available in the Documentation Center at https://docs.appeon.com.