OpenSheetWithParmAsDocument PowerScript function – PB Docs 126

OpenSheetWithParmAsDocument PowerScript function

Opens a sheet as a document within an MDI frame window for dockable windows.
OpenSheetWithParmAsDocument also stores a parameter in the system’s
Message object so that it is accessible to the opened sheet.

Applies to

Windows objects


Argument Description
sheetrefvar The name of any window variable that is not an MDI frame window.
OpenSheetWithParmAsDocument places a
reference to the open sheet in
parameter The parameter you want to store in the Message object when the
sheet is opened. Parameter must have one of these datatypes:

  • String
  • Double
  • 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 an MDI frame window.
sheetname A unique string identifier for the sheet, which is used when
layout is persisted.
tabalign (optional) A boolean that, when used, creates a new tab group and indicates
the alignment of the sheets in the group. When true, the tabs in the
group align vertically. When false, the tabs align


Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value
is null, OpenSheetWithParmAsDocument returns null. In some cases,
such as if the windowtype argument is invalid,
OpenSheetWithParmAsDocument 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.


Tabbed documents can be in more than one tab group. Users can create additional tab
groups by dragging one tab outside of the current group. If there is more than one
tab group, use the mdiframe argument to specify in which one to
open a sheet. Instead of specifying the parent window, specify an already open sheet
in the tab group where you want to open your new sheet.

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

Message object property Argument datatype
Message.DoubleParm Double
Message.PowerObjectParm PowerObject (PowerBuilder objects, including user-defined
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

Note: 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.

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x