PowerBuilder ‘Gotcha’ – Null Messagebox

Posted on Monday, August 30th, 2010 at 8:20 pm in

As with many methods in Powerbuilder, the ‘Messagebox’ function returns a NULL if any of the paramenters you send it are NULL. This can be problematic in your ‘defensive programming’ situations where you are informing the user of some type of error or condition. For Example:

ls_value = TRIM(data)
IF Len(ls_value) > 0 THEN
	SELECT Max(itemCode)
	INTO :ls_check
	FROM AB_Part
	WHERE itemNo = :ls_value
	USING SQLCA;
	IF IsNull(ls_check) THEN
		Messagebox(Parent.title,"Item " + ls_check + " is not valid!~nPlease enter a valid Item Number.")
		RETURN 1
	ELSE...

This code does not produce a messagebox since the value of ls_check is NULL thereby causing the messagebox text to be null.

Top