SELECTINDEX

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

Selects the item at index position num and updates the display.

Syntax

  1. print #handle.ext, "selectindex num"
  2. print #handle.ext, "selectindex "; indexVar

Hints

Index Selection. The index numbers begin with "1" in a Listbox or Combobox control. Remember, index numbers might not match array numbers (an array can have an index "0" for instance), especially if array items have been deleted and the list has been reloaded.

Example

' Using SELECTINDEX
nomainwin
a$(1) = "apple"
a$(2) = "orange"
a$(3) = "banana"
a$(4) = "pear"

listbox #win.lst, a$(), [getIndex], 10, 10, 120, 200

    open "Select Index Demo" for window as #win
    #win "trapclose Quit"

    ' Use SELECTINDEX to highlight the default selection
    #win.lst "selectindex 2"

    wait

sub Quit handle$
    close #handle$
    end
    end sub

[getIndex]
    #win.lst "selectionindex? indexNum"
    notice "You chose Index number ";indexNum
    wait

Useful Procedures

' Place a useful function or sub using this keyword here