Schultz’s PowerBuilder Notes

Getting a Reference to a Submenu

Getting a reference to the window’s menu is easily accomplished using the window’s MenuId property.  But what if you want to get a reference to a submenu and all you have is a string with the menu’s name?  This following function will do the trick: Read more »

August 1, 2009 Posted by rick130 | 1. PowerBuilder General, Menus, Powerscript | , , | 1 Comment

Setting the RowStatus

If you have worked with PowerBuilder for a while, you have learned that setting the status of a row is not always a straight forward procedure.  I have created a handy utility which will simplify this process.

Read more »

January 1, 2009 Posted by rick130 | 2. Datawindows, Datawindow PowerScript, Powerscript | , , , , , , , , , , | 4 Comments

Guaranteeing a Singleton

Because the datetime on the client machine may not be accurate, I wanted to write a function to get the current date and time from the server.  

For Sybase DBMS, this is simply achieved with the GetDate() function.  The problem is developing the SQL to return exactly one row everytime the function is called.  (It will still work if the SQL returns multiple rows, but you will have a lot of unecessary database traffic.)

Read more »

September 19, 2008 Posted by rick130 | Database, Powerscript | , , , , | No Comments Yet

Nulls

I find nulls to be the cause of so many bugs. Here are a few things that have helped me get my mind around this surprisingly confusing topic.

Let’s look at the following script, what would the result be?

Read more »

August 14, 2008 Posted by rick130 | Powerscript | , , , | 1 Comment

Negative Logic

I maintain several PowerBuilder applications which were written a long time ago by developers just starting out in PB. So I see a lot of odd code.

Here is an example of a script which has negative logic

Read more »

June 25, 2008 Posted by rick130 | Powerscript | , , , | 2 Comments

System Functions

Evaluate( )

The evaluate( ) function is available for use with Describe( ). Evaluate( ) lets you evaluate DataWindow expressions within a script using data in the DataWindow. It has the following syntax:

Read more »

May 26, 2008 Posted by rick130 | Powerscript | , , , , , , , , , , | No Comments Yet

Dynamically Changing DataWindow Properties

What is the difference between SELECT and PBSELECT

PBSELECT is generic database independent SQL which is stored in the DataWindow. The actual outer join SQL for native Sybase connection will differ from an ODBC Sybase connection.

Read more »

May 25, 2008 Posted by rick130 | Datawindow PowerScript, Powerscript | , , , , , , , | 1 Comment

Working with DDDW Properties

The following example returns the display value for the dept_id column for the current row:

String ls_rownum., ls_return

ls_rownum =  String(dw_1.GetRow( ))
ls_return = dw_1.Describe(“Evaluate(‘LookUpDisplay(dept_id)’,” + ls_rownum + “)”)

Read more »

May 13, 2008 Posted by rick130 | Drop Down Data Window (DDDW), Powerscript | , , , , , , , , , , , , , , | 1 Comment

How do I call a Function in an Ancestor?

Functions default behavior is to Override any existing function with the same name and signature. If you need to call the ancestor function, use the SUPER pronoun.

boolean lb_rc

// do some stuff

lb_rc = Super::of_Filter_others(as_err_msg)

// do some stuff

Return lb_rc

May 9, 2008 Posted by rick130 | Powerscript | , , , | No Comments Yet