Mastering PowerBuilder

HomePrevious Lesson: Expose Public Instance Variables
Next Lesson: Use of Unsupported datatypes generates an error

Allow NULL Values in Method Arguments

As a PowerBuilder programmer, this option might look strange for you, since you do not specify this type of option anywhere while defining a function/event.

One of the powerful features of PowerBuilder is the support for NULL values in simple data types. Because CORBA does not allow for NULL values in simple data types, PowerBuilder has defined an interoperable means for propagating nulls between clients and components. This requires an additional method argument that represents an array of values that indicate null status of each argument. If you check this option, the component will be generated with the additional "null status" method argument.

The argument is a CORBA sequence (unbounded array) of booleans. The first element is the null status of the return value, and every other element corresponds to a method parameter. A method with two regular parameters would have a final nullflags parameter with three booleans in the sequence, one for the return value and one each for the parameters. The nullflags parameter is declared as an inout, meaning it will be passed to and from the server. Also, there will always be a boolean for the return value, even if there is no return value to the method.

You do not have to change their function names or explicitly add a parameter for the nullflags. PowerBuilder handles these changes automatically; the project wizard defines the method and nullflags parameter in the IDL. These changes will not be seen either in PowerBuilder proxies or in PowerBuilder NVO components. The PowerBuilder VM will automatically translate the status from the nullflags booleans to the appropriate PowerBuilder variables. Null propagation will work just as it does in conventional PowerBuilder and Distributed PowerBuilder.

This feature is not supported for public instance variables. NULL value propagation will work only for simple data types. Null values in a structure or array will not be maintained. If you intend to reference PowerBuilder-generated components with other languages such as Java, there are several things to consider:

PowerBuilder components supporting NULL values that are deployed to Jaguar will have their interface altered from what was defined in the User Object painter. This will be apparent in the component IDL and in the C++ or Java stubs generated in Jaguar.

Client applications will also need to be written to be aware of the additional argument that indicates the NULL status of arguments and the return code.
HomePrevious Lesson: Expose Public Instance Variables
Next Lesson: Use of Unsupported datatypes generates an error