Syntax 1 For user objects of a known datatype
Description
Opens a user object of a known datatype and stores a parameter
in the system’s Message object.
Controls
Window objects and visual user objects
Syntax
|
1 |
<span>objectname</span>.<span>OpenUserObjectWithParm</span> ( <span>targetobjectvar</span>, <span>parameter</span> <br> {, <span>x</span>, <span>y</span> } ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the window or user object |
|
targetobjectvar |
The name of the target object you want |
|
parameter |
The parameter you want to store in the
|
|
x |
The x coordinate in PowerBuilder units |
|
y |
The y coordinate in PowerBuilder units |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs. If any argument’s value is null, OpenUserObjectWithParm returns null.
Usage
The system Message object has three properties for storing
data. Depending on the datatype of the parameter specified for OpenUserObjectWithParm,
scripts for the opened user object check one of the following properties:
|
Message object property |
Argument datatype |
|---|---|
|
message.DoubleParm |
Numeric |
|
message.PowerObjectParm |
PowerObject (PowerBuilder objects, including user-defined |
|
message.StringParm |
String |
In the target user object, consider accessing the value passed
in the Message object immediately, because some other script may
use the Message object for another purpose.
Avoiding null object references
When you pass a PowerObject as a parameter, you are passing
a reference to the object. The object must exist when you refer
to it later or you get a null object reference, which causes an
error. For example, if you pass the name of a control on a window
that is being closed, that control will not exist when a script
accesses the parameter.
See also the usage notes for OpenUserObject, all of which
apply to OpenUserObjectWithParm.
Examples
This statement displays an instance of a user object
named u_Employee in the window w_emp and
stores the string James Newton in
Message.StringParm. The Constructor event script for the user object
uses the string parameter as the text of a StaticText control st_empname in
the object. The script that opens the user object has the following
statement:
|
1 |
w_emp.OpenUserObjectWithParm(u_Employee, "Jim Newton") |
The target user object’s Constructor event
script has the following statement:
|
1 |
st_empname.Text = Message.StringParm |
The following statements display an instance of a
user object u_to_open in
the window w_emp and store a number
in message.DoubleParm:
|
1 |
u_employee u_to_open |
|
1 |
integer age = 50 |
|
1 |
w_emp.<span>OpenUserObjectWithParm</span>(u_to_open, age) |