Macros and the IBM CognosScript Language  7.5.0
IBM CognosScript Statements and Functions >

DropListBox Statement

Description

Creates a drop-down list of choices.

Syntax A

DropListBox x , y , dx , dy , text$ , .field

Syntax B

DropListBox x , y , dx , dy , stringarray$() , .field

where:

is:

x , y

The upper left corner coordinates of the list box, relative to the upper left corner of the dialog box.

dx , dy

The width and height of the combo box in which the user enters or selects text.

text$

A string containing the selections for the combo box.

stringarray$

An array of dynamic strings for the selections in the combo box.

.field

The name of the dialog-record field that will hold the text string entered in the text box or chosen from the list box.

Comments

The x argument is measured in 1/4 system-font character-width units. The y argument is measured in 1/8 system-font character-width units. (See Begin Dialog for more information.)

The text$ argument must be defined, using a Dim Statement, before the Begin Dialog statement is executed. The arguments in the text$ string are entered as shown in the following example:

dimname = "listchoice"+Chr$(9)+"listchoice"+Chr$(9)+"listchoice"...

The string in the text box will be recorded in the field designated by the .field argument when the OK button (or any pushbutton other than Cancel) is pushed. The field argument is also used by the dialog statements that act on this control.

A drop list box is different from a list box. The drop list box only displays its list when the user selects it; the list box also displays its entire list in the dialog box.

Use the DropListBox statement only between a Begin Dialog and an End Dialog statement.

Example

This example defines a dialog box with a drop list box and the OK and Cancel buttons.

Sub main
   Dim DropListBox1() as String
   ReDim DropListBox1(3)
   For x=0 to 2
     DropListBox1(x)=Chr(65+x) & ":"
   Next x
   Begin Dialog UserDialog 186, 62, "CognosScript DialogBox"
      Text  8, 4, 42, 8, "Drive:", .Text3
      DropListBox  8, 16, 95, 44, DropListBox1(), _ 
         .DropListBox1
      OKButton  124, 6, 54, 14
      CancelButton  124, 26, 54, 14
   End Dialog
   Dim mydialog as UserDialog
   On Error Resume Next
   Dialog mydialog
   If Err=102 then
      MsgBox "Dialog box canceled."
   End If
End Sub

See Also

Begin Dialog...End Dialog Statement

Button Statement

ButtonGroup Statement

CancelButton Statement

Caption Statement

CheckBox Statement

ComboBox Statement

DropComboBox Statement

ListBox Statement

OKButton Statement

OptionButton Statement

OptionGroup Statement

Picture Statement

StaticComboBox Statement

Text Statement

TextBox Statement