Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

We all know that PowerBuilder is great for developing client server applications. Often there is a need to perform batch processing on schedule, usually at night when nobody is around. These batch programs can easily be developed in PowerBuilder. All you have to do is create a non-visual custom class object and call functions in it from the application open event.

A batch program of mine writes status messages to a log file and can run a long time. The run time can be anywhere from 1 minute to over an hour depending on the input volume. PowerBuilder batch programs do not have the ability to write to the command window so the user monitoring the program has no way to tell how it is progressing without periodically opening the log file.

I searched the web looking for a solution that would allow my program to write to the command window. I came across the following article from the PowerBuilder Developer's Journal:

Writing Console Applications with PowerBuilder 9

By XUE-SONG WU

http://pbdj.sys-con.com/node/42603

This article is a demo of PBNI, a feature introduced in version 9 that allows for two types of C/C++ integration. The first type allows C/C++ programs to call PowerBuilder code. The second type allows you to create PowerBuilder objects in C/C++. The article uses both types.

First is an executable that uses the PBNI function RunApplication to execute an application starting with the open event. Second is a .PBX file which is similar to a .DLL file. In PowerBuilder you right click a library in the system tree and select 'Import PB Extension' from the popup menu. Choose the .PBX file and an object is created that forms an interface to the .PBX that you can use just like it were a regular PowerScript object. The object contains functions that you use to interact with the command window.

I made a couple of improvements:

Upgraded the project from Visual C/C++ 6 to Visual Studio 2012.

Added an argument to specify the PowerBuilder VM filename so that it can be used with any version of PowerBuilder.

Added an optional argument that is passed to the application open event commandline argument.

Added a function to set a program return code.

Added a program icon to the executable and changed its name from 'pb' to 'pbconsole'.

I put a zip file containing the Visual Studio project on my website. It includes PowerBuilder 9 and 10.5 examples. You can download it from here:

Topwiz Software - Tools

8 Comments
Labels in this area