GetOption

Prompts the user for one or more command-line options.

Syntax

Rhino.GetOption (strPrompt, arrOptions)

Parameters

strPrompt

Required.  String.  A prompt or message.

arrOptions

Required.  Array.  An array containing one or more command line option arrays.

A command-line option array contains information that defines the command-line option. The first element of a command-line option array identifies the type of command line option. The type of command-line option determines how many additional elements the command-line option array must contain.

There are 5 types of command-line options:

Value

Description

0

Single, or one, shot option. This option array will show a click-able single-shot option in the form of <strName> on the command line. The default option value is always False. If clicked, a True value will be returned indicating that it was clicked. The array elements are as follows:

Element

Parameter

Description

1

strName

Required.  String.  The name of the command-line option, as it will appear on the command-line.

 

1

Boolean option. This option array will show a click-able Boolean option in the form of <strName=strFalse/strTrue> on the command line. The array elements are as follows:

Element

Parameter

Description

1

strName

Required.  String.  The name of the command-line option, as it will appear on the command-line.

2

strFalse

Required.  String.  A string identifying the False value.

3

strTrue

Required.  String.  A string identifying the True value.

4

blnValue

Required.  Boolean.  The default option value.

 

2

Integer option. This option array will show a click-able integer option in the form of <strName=intValue> on the command line. The array elements are as follows:

Element

Parameter

Description

1

strName

Required.  String.  The name of the command-line option, as it will appear on the command-line.

2

intValue

Required.  Number.  The default option value.

3

strPrompt

Optional.  String.  The prompt that will appear on the command-line when clicked.

4

intLowerLimit

Optional.  Number.  The smallest allowable value.

5

intUpperLimit

Optional.  Number.  The largest allowable value.

 

3

Number option. This option array will show a click-able number option in the form of <strName=dblValue> on the command line. The array elements are as follows:

Element

Parameter

Description

1

strName

Required.  String.  The name of the command-line option, as it will appear on the command-line.

2

dblValue

Required.  Number.  The default option value.

3

strPrompt

Optional.  String.  The prompt that will appear on the command-line when clicked.

4

dblLowerLimit

Optional.  Number.  The smallest allowable value.

5

dblUpperLimit

Optional.  Number.  The largest allowable value.

 

4

List option. This option array will show a click-able list option in the form of <strName=intIndex> on the command line. Then the item is clicked, a list of click-able items will appear. The array elements are as follows:

Element

Parameter

Description

1

strName

Required.  String.  The name of the command-line option, as it will appear on the command-line.

2

arrList

Required.  Array.  An array of strings that will appear on the command-line when the option is clicked.

3

intIndex

Required.  Array.  The default option value, which is the index of the current item in arrList.

 

Returns

Array

An array of command-line option values, updated by the user, in the order in which they were passed to the function, if successful.

Null

If not successful, or on error.

Example

Sub TestOptions

 

  Const OPT_SGL = 0

  Const OPT_BLN = 1

  Const OPT_INT = 2

  Const OPT_DBL = 3

  Const OPT_LST = 4

 

  Dim arr0, arr1, arr2, arr3, arr4

  Dim lst, opt, rc, i

 

  lst = Array("One", "Two", "Three", "Four")

 

  arr0 = Array(OPT_SGL, "Single")

  arr1 = Array(OPT_BLN, "Boolean", "Off", "On", false)

  arr2 = Array(OPT_INT, "Integer", 4, "New value", 2, 10)

  arr3 = Array(OPT_DBL, "Double", 34.76, "New value", 1.0, 100.0)

  arr4 = Array(OPT_LST, "List", lst, 0)

 

  opt = Array(arr0, arr1, arr2, arr3, arr4)

 

  rc = Rhino.GetOption("Scripting options", opt)

  If IsArray(rc) Then

    For Each i in rc

      Call Rhino.Print(i)

    Next

  End If

 

End Sub

Also See

GetBoolean

GetString