Search code examples
visual-prologwin-prolog

Visual Win-Prolog Listbox Selected Item Index


I was going through the manual file Win-W32.PDF but I couldn't find how to get the selected item in a listbox.
i.e the index of test3 in this case
enter image description here

I know that: test being the name, 3 being the id of the listbox
wlbxsel((test, 3),1, X) get the status of item 1
wlbxsel((test, 3),1, 0) deselects item 1

in the same manner, I tried wlbxsel((test, 3),X, 1) thinking it would return the index of the selected item but I got Error 22 : Instantiation Error.

Any pointers, documentations, or references are highly appreciated.


Solution

  • It's a bit confusing at first because of the prefix. we need to use wlst not wlbx

    To get the index of the selected item
    wlstsel((test, 3), Position)
    then get the selected item using the index
    wlstget((test, 3), Position, String, Item)