Advanced PowerBuilder

HomePrevious Lesson: Solutions To Common Debugging Problems
Next Lesson: KeyDown(), GetObjectAtPointer()

MessageBox()

Instead of using the step-by-step technique of debugging, you might decide to use the PowerBuilder MessageBox() function to indicate the passage of some code, together with pertinent information about the state of some variable or property.

In this case, problem arises only when the variable in display has a NULL value. In this case, PowerBuilder neglects to display the message box. In the debug window, you can see the MessageBox() being executed, but it never appears on the screen.

This often happens when dealing with embedded SQL commands. If the column you are selecting isn't protected by a NOT NULL flag or a default value, you run the risk of acquiring a NULL and falling fowl to this problem.

You can't perform a check with an equality sign, as shown below:
If Variable = NULL then ...

PowerBuilder supports an IsNull() function to check if the variable in question has a NULL value. You can also place NULL value checks in the embedded SQL:
SELECT "product_master"."product_description" 
   INTO :lProductDesc:lDescInd1 
   FROM "product_master" 
   WHERE "product_master"."product_no" = :lProductNo ;

In the above example, you can check lDescInd1 for the presence of a NULL value in the lProductDesc variable. You will be learning more about embedded SQL in the coming session.
HomePrevious Lesson: Solutions To Common Debugging Problems
Next Lesson: KeyDown(), GetObjectAtPointer()