Displaying Data from a Pointer Array in a Dialog Box

Description

Assume that you want to display a list box showing the company names in a array. To do this, the syntax for the list box would be:

[.30,15index^#customer[[[\].name]

The actual syntax for referencing the 'name' column in the array is customer.[].name. However, since this is within the definition of a list box control (which starts and ends with '[' and ']', the ']' in customer.[].name needs to be 'escaped' so that Alpha Anywhere does not interpret it as the end of the control definition. The escape character in Alpha Anywhere is the '\'. So the syntax becomes customer[\].name. Typically, when you display data from one of the array columns on the dialog box, you will also want to display data from other corresponding columns in the array. For example, you might also want to display data from the Address, City, State and Zip columns. To do this, you dimension the list box variable ('index' in the above example) as Numeric. as the user moves in the list box from customer[1].name to customer[2].name, the value of index changes from 1 to 2, and the fields displayed on the dialog will change as well. The following example will make this clear. This script displays a list box showing the company name in a list box and the other corresponding data in text boxes:

DIM customer[3] as P
Customer[1].name = "Alpha"
Customer[1].address = "1 Main St."
Customer[1].city = "Boston"
Customer[1].state = "MA"
Customer[1].zip = "02116"
Customer[1].phone = "6175551212"
Customer[2].name = "Beta"
Customer[2].address = "2 Center St."
Customer[2].city = "New York"
Customer[2].state = "NY"
Customer[2].zip = "01001"
Customer[2].phone = "2125551212"
Customer[3].name = "Gamma"
Customer[3].address = "3 Maple Ln."
Customer[3].city = "Cambridge"
Customer[3].state = "MA"
Customer[3].zip = "02139"
Customer[3].phone = "6178641212"
dim index as N
index = 1
ui_dlg_box("Customers",<<%dlg%
{region}
[.30,10index^#customer[[[\].name];
{endregion}|
{region}
Address: |[.30customer[[[index\].address];
City: |[.30customer[[[index\].city];
State: |[.30customer[[[index\].state];
Zip: |[.30customer[[[index\].zip];
Phone: |[.30customer[[[index\].phone];
{endregion};
{region}
<10&OK!ok> <10&Cancel!cancel>
{endregion}
%dlg%)

This script displays this dialog box:

images/XD_Pointer Array.gif

Limitations

Desktop applications only.

See Also