You can use the Set Selected(Item Number, <State>, <Run Script(0|1)>) message to pre-select an item. You can use this message separately to a saved display box reference, or you can specify it inline as a list box << message.
To retrieve the selected value, use the Get Selected message, which returns the value of the selected item. The Get Selected Indices message returns the index number of the selected item.
listObj = List Box(
listObj << Get Selected,
listObj << Get Selected Indices
listObj = List Box(
listObj << Get Selected,
listObj << Get Selected Indices
In the preceding examples, the Print expression is executed when the Set Selected message is completed. To prevent the script from running, include Run Script(0) as the last argument. Run Script( 0|1 ) controls whether a display box on-change script runs after a Set or Set Selected message.
listObj = List Box(
listObj << Get Selected,
listObj << Get Selected Indices
With Run Script( 1 ), the script is executed when the Set message is completed, even if the value is unchanged. (The script does not run again if the user selects the same value.) With Run Script( 0 ), the script does not run.
On most interactive display boxes, the script does not run on most interactive display boxes if you leave out Run Script(). However, on List Box(), the script runs by default, which is consistent with previous behavior.