GetItem

GetChoice


The GetChoice function opens a dialog showing two choices to be made. This function returns the choice index and the button that was clicked. All text labels can be configured or defaults can be used.

 

Syntax

nChoice, bOK = GetChoice( sLabels )

nChoice, bOK = GetChoice( sLabels, n )

nChoice, bOK = GetChoice( sLabels, n, sPrompt )

nChoice, bOK = GetChoice( sLabels, n, sPrompt, sTitle )

bullet.gif    sLabels is the list of choice labels, separated by \n.

bullet.gif    n is the index of the initial choice (1 or 2). If nil, item 1 is initially chosen.

bullet.gif    sPrompt specifies a message above the choices. If nil, a default prompt is used.

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

bullet.gif    If [OK] is clicked, the function returns nChoice = 1 or 2, and bOK = true.

bullet.gif    If the dialog is canceled, 1, 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 sLabels argument specifies the strings to be used for the 2 bullet labels. These labels are specified in one string separated by a new line character \n, with the top label first. For example, to specify the labels as "First label" and "Second label", pass the sLabels argument as

     "First label\nSecond label".

The choice is returned as nResult = 1 or 2. If the User clicks [OK], then this method returns bOK=true. Otherwise, if the user clicks [Cancel], then this method returns bOK=false.

Examples

Example 1. The dialog shown above was created using the following code:

 

n, bOK = GetChoice(

 

           "The first choice.\nThe second choice.",

-- labels

           2,

-- initial choice

           "Choose between these options:",

-- prompt

           "This is a Choice dialog" )

-- dialog title

Example 2. A default dialog that specifies strings and title would use the following code:

 

n, bOK = GetChoice(

 

           "The first choice.\nThe second choice.",

-- labels

           nil,

-- default initial choice

           nil,

-- default prompt

           "This is a Choice dialog" )

-- dialog title

Example 3. A default dialog with only the strings specified might code like this (you can skip the intermediate nil's:

 

n, bOK = GetChoice(

-- labels only

                    "The first choice.\n" ..

                    "The second choice." )

 

Related Topics

GetItem

GetTrueFalse


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