GetItem


Opens a dialog for choosing from a bullet list.The GetItem function opens a dialog showing a list of items in a list box. This function returns the index of the selected item and the button that was clicked. All labels can be configured. This is similar to the GetItemStr function except that it returns the index of the selected string and not the string itself.

List box is shown open with 4 choices.

Syntax

nIndex, bOK = GetItem( sLabels )

nIndex, bOK = GetItem( sLabels, n )

nIndex, bOK = GetItem( sLabels, n, sPrompt )

nIndex, bOK = GetItem( sLabels, n, sPrompt, sTitle )

bullet.gif    sLabels is a string containing the list of item labels, separated by \n.

bullet.gif    n is the index of the initial choice, beginning with 1. If nil, item 1 is initially chosen.

bullet.gif    sPrompt is the message above the list box. If nil, a default prompt is used.

bullet.gif    sTitle is the window title. If nil, a default title is used.

bullet.gif    If [OK] is clicked, the function returns the selected string and bOK = true.

bullet.gif    If the dialog is canceled, "", false is returned.

Remarks

All arguments following sLabels are optional and assume default values after the last argument you specify. To use a default argument but follow it with a specified argument, use a nil in its place.

The items are specified as a single string using \n to separate the individual items. For example, to specify the labels as "First item" and "Second item", pass the sLabels argument as "First item\nSecond item".

The index of the choice is returned as nIndex, beginning at 1. If the User clicks [OK], then bOK = true. Otherwise, if the user clicks [Cancel], then bOK = false.

Example

The window shown above was created using the following code. Note that the last 2 arguments, the prompt and the window title, were omitted and left to the defaults:

nItem, bOK = GetItem(

 

            "First choice...\n" ..

            "Second choice...\n" ..

            "Third choice...\n" ..

            "The last choice",

-- labels (4 lines concatenated by ..)

            2)

-- initial choice is item 2

The following script shows how to accrue the label string by concatenation using the top heading titles of a CGridView. First, create a label string named str, then call GetItem to return the column of the selected title:

G = attachlist_gridview()

-- attach a grid from the desktop

str = ""

-- initialize the string

for nCol = 1, G:GetNumCols() do

-- for each grid column

     str = str .. G:GetStr(nCol,0) .. "\n"

-- concatenate the title and \n

end

 

nCol, bOK = GetItem(str)

-- open the dialog to select the column

Related Topics

GetItemStr, GetChoice

 


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.