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

Using window arrays – PB Docs 100 – PowerBuilder Library

Using window arrays – PB Docs 100

Using window arrays

To create an array of windows, declare an array of the datatype
of the window. For example, the following
statement declares an array named myarray,
which contains five instances of the window w_employee:

You can also create unbounded arrays of windows if the number
of windows to be opened is not known at compile time.

Opening an instance using an array

To open an instance of a window in an array, use the Open function
and pass it the array index. Continuing the example above, the following
statements open the first and second instances of the window w_employee:

note.gif Moving first instance opened The statements in this example open the second instance of
the window at the same screen location as the first instance. Therefore,
you should call the Move function in the script
to relocate the first instance before the second Open function
call.

Manipulating arrays

Using arrays of windows, you can manipulate particular instances
by using the array index. For example, the following statement hides
the second window in the array:

You can also reference controls in windows by using the array
index, such as:

note.gif Opening many windows When you open or close a large number of instances of a window,
you may want to use a FOR…NEXT control structure
in the main window to open or close the instances. For example:

Creating mixed arrays

In the previous example, all windows in the array are the
same type. You can also create arrays of mixed type. Before you
can understand this technique, you need to know one more thing about
window inheritance: all windows you define are actually descendants
of the built-in datatype window.

Suppose you have a window w_employee that
is defined from scratch, and w_customer that
inherits from w_employee. The complete
inheritance hierarchy is the following:

Figure 6-2: Window inheritance hierarchy

mgwin02.gif

The system-defined object named window is the ancestor of
all windows you define in PowerBuilder. The built-in object named
window defines properties that are used in all windows (such as
X, Y, and Title).

If you declare a variable of type window, you can reference
any type of window in the application. This is because all user-defined
windows are a kind of window.

The following code creates an array of three windows. The
array is named newarray. The array can reference
any type of window, because all user-defined windows are derived
from the window datatype:

The code uses this form of the Open function:

where windowVariable is a variable of
type window (or a descendant of window) and windowType is
a string that specifies the type of window.

The preceding code opens three windows: an instance of w_employee,
an instance of w_customer, and an
instance of w_sales.

Using arrays versus reference variables

Table 6-1 shows
when you use reference variables and when you use arrays to manipulate
window instances.

Table 6-1: Arrays as opposed to reference
variables
Item Advantages Disadvantages
Arrays You can refer to particular instances. Arrays are more difficult to use. For
example, if the user closes the second window in an array, then
wants to open a new window, your code must determine whether to
add a window to the end of the array (thereby using more memory
than needed) or find an empty slot in the existing array for the
new window.
Reference variables Easy to use–PowerBuilder manages them
automatically.
You cannot manipulate particular instances
of windows created using reference variables.

Suppose you use w_employee to
provide or modify data for individual employees. You may want to
prevent a second instance of w_employee opening for
the same employee, or to determine for which employees an instance
of w_employee is open. To do this
kind of management, you must use an array. If you do not need to
manage specific window instances, use reference variables instead
to take advantage of their ease of use.


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