Syntax 2 For user objects of unknown datatype
Description
Opens a user object when the datatype of the user object is
not known until the script is executed. In addition, OpenUserObjectWithParm stores
a parameter in the system’s Message object so that it is
accessible to the opened object.
Controls
Window objects and user objects
Syntax
1 |
<span>objectname</span>.<span>OpenUserObjectWithParm</span> ( <span>targetobjectvar</span>, <span>parameter</span>, <br> <span>targetobjecttype</span> {, <span>x</span>, <span>y</span> } ) |
Argument |
Description |
---|---|
objectname |
The name of the window or user object |
targetobjectvar |
A variable of datatype DragObject. OpenUserObjectWithParm places |
parameter |
The parameter you want to store in the
|
targetobjecttype |
A string whose value is the datatype |
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.
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 will get a null object reference, which causes
an error. For example, if you pass the name of a control on an object
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
The following statement displays an instance of a
user object u_data of type u_benefit_plan at
location 20,100 in the container object w_hresource.
The parameter “Benefits” is stored in message.StringParm:
1 |
DragObject u_data |
1 |
w_hresource.<span>OpenUserObjectWithParm</span>(u_data, & |
1 |
"Benefits", "u_benefit_plan", 20, 100) |
These statements open a user object of the type specified
in the string s_u_name and
store the reference to the object in the variable u_to_open.
The script gets the value of s_u_name,
the type of user object to open, from the database. The parameter
is the text of the SingleLineEdit sle_loc,
so it is stored in Message.StringParm. The target object is at the
default coordinates 0,0 in the objectname object w_info:
1 |
DragObject u_to_open |
1 |
string s_u_name, e_location |
1 |
1 |
e_location = sle_location.Text |
1 |
1 |
SELECT next_userobj INTO <span>:</span> s_u_name |
1 |
FROM routing_table |
1 |
WHERE ... ; |
1 |
1 |
w_info.OpenUserObjectWithParm(u_to_open, & |
1 |
e_location, s_u_name) |
The following statements display a user object of
the type specified in the string s_u_name and
store the reference to the object in the variable u_to_open. The
parameter is numeric, so it is stored in message.DoubleParm. The
target object is at the coordinates 100,200 in the objectname object w_emp:
1 |
userobject u_to_open |
1 |
integer age = 60 |
1 |
string s_u_name |
1 |
1 |
s_u_name = sle_user.Text |
1 |
w_emp.<span>OpenUserObjectWithParm</span>(u_to_open, age, & |
1 |
s_u_name, 100, 200) |