CloseTab PowerScript function
Description
Removes a tab page from a Tab control that was opened previously
with the OpenTab or OpenTabWithParm function. CloseTab executes
the scripts for the user object’s Destructor event.
Controls
Tab controls
Syntax
|
1 |
<span>tabcontrolname</span>.<span>CloseTab </span>( <span>userobjectvar</span> ) |
|
Argument |
Description |
|---|---|
|
tabcontrolname |
The name of the Tab control containing |
|
userobjectvar |
The name of the user object you want |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs. If any argument’s value is null, CloseTab returns null.
The return value is usually not used.
Usage
CloseTab closes a user object that has
been opened as a tab page and releases the storage occupied by the
object and its controls.
When you call CloseTab, PowerBuilder removes
the tab page from the control, closes it, executes the script for
the Destructor event (if any), and then executes the rest of the
statements in the script that called the CloseTab function.
CloseTab also removes the user object from
the Tab control’s Control array, which is a property that
lists the tab pages within the Tab control. If the closed tab page
was not the last element in the array, the index for all subsequent
tab pages is reduced by one.
After a user object is closed, its properties, instance variables,
and controls can no longer be referenced in scripts. If a statement
in the script references the closed user object or its properties
or instance variables, an execution error will result.
Examples
These statements close the tab page user object u_employee and
then open the user object u_departments in
the Tab control tab_personnel:
|
1 |
tab_personnel.<span>CloseTab</span>(u_employee) |
|
1 |
tab_personnel.OpenTab(u_departments) |
When the user chooses a menu item that closes a user
object, the following excerpt from the menu item’s script
prompts the user for confirmation before closing the u_employee user
object in the window to which the menu is attached:
|
1 |
IF MessageBox("Close ", "Close?", & |
|
1 |
Question!, YesNo!) = 1 THEN |
|
1 |
// User chose Yes, close user object. |
|
1 |
ParentWindow.<span>CloseTab</span>(u_employee) |
|
1 |
// If user chose No, take no action. |
|
1 |
END IF |