Discussions related to Visual Prolog
kimsmith64
Posts: 2
Joined: 24 Nov 2021 14:26

Overview documentation and listBox index problem

Unread post by kimsmith64 »

Thank you very much. Apart from the online resource are there any other resources I can use. I could do with some basic language structure. I am attempting an expert system, and I need to use list boxes and checkboxes to access the input data and struggling with getting the list item and not the index number to be taken to the last screen where I will then be using that data to match against my stored data.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1318
Joined: 28 Feb 2000 0:01

Re: Overview documentation and listBox index problem

Unread post by Thomas Linder Puls »

The PFC library code contains some documentation about individual predicates, etc. That is a kind of bottom-up information. The top-down information that gives overview, structure, etc is limited to what you find here on line.

And you are more than welcome to ask questions here.

For your specific problem with list boxes. I will give you a few hints for locating useful information for your problem. You have an "index" into a listBox but you actually want the related data. First I would jump to the listBox interface and in that file I would search for the word "index" to see what operations that has anything to do with "index".

You will however find that none of the operations in that file seems relevant for your problem :-(.

But then you should notice that listBox supports the listControl interface:

Code: Select all

interface listBox supports listControl ...
There may also be relevant "index" operations in that interface so I would repeat the "index" search in the listControl interface file. Here I find the operation:

Code: Select all

predicates     getAt : (positive Index) -> string Item.     % @short Retrieves the string item #Item, which is at the #Index     % position in the list of the list control.<br>     % @end
And that sounds like a useful predicate for you.
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 393
Joined: 5 Nov 2000 0:01

Re: Overview documentation and listBox index problem

Unread post by Harrison Pratt »

Take a look at my guiControlSupport class to see some ways to access and manipulation listBox, listButton and listEdit controls.

You can simply add the class files ( .cl, .i & .pro ) files to an appropriate package and inherit it into the implementation of your form or dialog like this extract from an issueEditor form I use:

Code: Select all

implement issueEditor inherits formWindow, guiControlSupport     open core, vpiDomains ... end implement issueEditor
Now you can use the guiControlSupport predicates directly in your form or dialog.

You should also note that a listEdit control is a combination of an edit control and a listbox control. The predicates selectOrAdd_ListEdit/1 and copyEditTextToList/1 in guiControlSupport add some convenient functionality for listEdit controls.
Attachments
guiControlSupport.zip
(2.04 KiB) Downloaded 36 times
Harrison Pratt
VIP Member
Posts: 393
Joined: 5 Nov 2000 0:01

Re: Overview documentation and listBox index problem

Unread post by Harrison Pratt »

Listbox, listbutton and listEdit all inherit from listControl so you can collect the selected strings from a mixed group of these type controls like this:

Code: Select all

predicates % FAIL if any control does not have a selected string     tryGetSelectedStrings : (listControl* CtrlList) -> string* SS determ. clauses     tryGetSelectedStrings(CtrlList) = SS :-         SS =             [ S ||                 Ctrl in CtrlList,                 [S] = Ctrl:getSelectedItems()             ],         list::length(SS) = list::length(CtrlList).   predicates % Return selected string or ElseStr for each control     getSelectedStringsElse : (listControl* CtrlList, string ElseStr) -> string* SS. clauses     getSelectedStringsElse(CtrlList, ElseStr) = SS :-         SS =             [ S ||                 Ctrl in CtrlList,                 ([S] = Ctrl:getSelectedItems() orelse S = ElseStr)             ].
Post Reply