Subscribe Bookmark RSS Feed

How to make input parameter optional in script?

zhouye0

Community Trekker

Joined:

Mar 2, 2016

lb7 = Col List Box( max selected( 1 ), nlines( 1 ), onchange( b = 1 ) ),

Button Box("Ok",

specCon[7] = lb7 << Get Items;)

Lets say that I occasionally want to leave lb7 empty as it is an optional parameter, how do I do it without the script giving me an error everytime I run it?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

The <<GetItems message returns a list.  You can use nItems( ... ) to find out if there are zero items in the list.

show( lb7 << Get Items, nitems(lb7 << Get Items));

11142_pastedImage_3.png

lb7 << Get Items = {};

N Items(lb7 << Get Items) = 0;

11141_pastedImage_2.png

lb7 << Get Items = {"height"};

N Items(lb7 << Get Items) = 1;

Craige
1 REPLY
Solution

The <<GetItems message returns a list.  You can use nItems( ... ) to find out if there are zero items in the list.

show( lb7 << Get Items, nitems(lb7 << Get Items));

11142_pastedImage_3.png

lb7 << Get Items = {};

N Items(lb7 << Get Items) = 0;

11141_pastedImage_2.png

lb7 << Get Items = {"height"};

N Items(lb7 << Get Items) = 1;

Craige