Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

OpenSheetWithParm – PB Docs 2019 – PowerBuilder Library

OpenSheetWithParm – PB Docs 2019

OpenSheetWithParm

PowerScript function

Description

Opens a sheet within an MDI (multiple document interface) frame
window and creates a menu item for selecting the sheet on the specified
menu, as OpenSheet does. OpenSheetWithParm also stores a parameter in the
system’s Message object so that it is accessible to the opened
sheet.

Applies to

Window objects

Syntax

Argument

Description

sheetrefvar

The name of any window variable that is not an MDI frame
window. OpenSheetWithParm places a reference to the open sheet
in sheetrefvar.

parameter

The parameter you want to store in the Message object when
the sheet is opened. Parameter must have one of these
datatypes:

  • String

  • Numeric

  • PowerObject

windowtype (optional)

A string whose value is the datatype of the window you
want to open. The datatype of windowtype must be the same or a
descendant of sheetrefvar.

mdiframe

The name of the MDI frame window in which you want to open
this sheet.

position (optional)

The number of the menu item (in the menu associated with
the sheet) to which you want to append the names of the open
sheets. Menu bar menu items are numbered from the left,
beginning with 1. The default is to list the open sheets under
the next-to-last menu item.

arrangeopen (optional)

A value of the ArrangeOpen enumerated datatype specifying
how you want the sheets arranged in the MDI frame when they are
opened:

  • Cascaded! — (Default) Cascade the sheet relative to
    other open sheets so that its title bar is below the
    previously opened sheet.

  • Layered! — Layer the sheet so that it fills the frame
    and covers previously opened sheets.

  • Original! — Open the sheet in its original size and
    cascade it.

Return value

Integer.

Returns 1 if it succeeds and -1 if an error occurs. If any
argument’s value is null, OpenSheetWithParm returns null. In some cases,
such as if the windowtype argument is invalid, OpenSheetWithParm throws a
runtime error and does not return a value; therefore, it is recommended
that you both test the return value and wrap the function call in a
try-catch block as shown in the first example in the Examples
section.

Usage

The system Message object has three properties for storing data.
Depending on the datatype of the parameter specified for
OpenSheetWithParm, scripts for the opened sheet would check one of the
following properties.

Message object property

Argument datatype

Message.DoubleParm

Numeric

Message.PowerObjectParm

PowerObject (PowerBuilder objects, including user-defined
structures)

Message.StringParm

String

In the opened window, it is a good idea to access 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.

Opening response windows

Do not use the OpenSheetWithParm function to open a response
window.

See the usage notes for OpenSheet, which also apply to
OpenSheetWithParm.

Examples

This example opens the sheet w_child_1 in the MDI frame MDI_User in
its original size and stores MA in message.StringParm. It appends the
names of the open sheet to the second menu item in the menu bar of
MDI_User (the menu associated with w_child_1). OpenSheetWithParm might
return -1 or throw a runtime error if the call fails. To ensure that both
of these possibilities are trapped, this example checks the return value
of the function and uses a try-catch statement to catch a possible runtime
error:

The next example illustrates how to access parameters passed in the
Message object. These statements are in the scripts for two different
windows. The script for the first window declares child as a window and
opens an instance of w_child_1 as an MDI sheet. The name of the sheet is
appended to the fourth menu item associated with w_child_1 and is
layered.

The script also passes a reference to the SingleLineEdit control
sle_state as a PowerObject parameter of the Message object. The script for
the Open event of w_child_1 uses the text in the edit control to determine
what type of calculations to perform. Note that this would fail if
sle_state no longer existed when the second script refers to it. As an
alternative, you could pass the text itself, which would be stored in the
String parameter of Message.

The second script determines the text in the SingleLineEdit and
performs processing based on that text.

The script for the first window is:

The second script, for the Open event in w_child_1, is:

See also

ArrangeSheets

OpenSheet


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x