Hello everyone. I’m making an interface for my expert system. Faced with the problem of multiple choice/tick-box/multiple selection. I’m trying and testing on a small example. Problem: after I select the options, I can’t continue working with them. Either errors or outputs as @274576025436. Ideally: add all the selected options to the list.
Just select Option 1, Option 2, Option 3, Option 4, I select Option 1, Option 3, get the message [‘Option 1’, ‘Option 3’].
I also found this code on github:
link to github
If you can help me, I will be very grateful, because I have been struggling with this problem for a long time. Entering numbers of answer options from the keyboard does not look so attractive.
Here is my test code on which I am trying to implement this:
:- use_module(library(pce)).
% Predicate to create a window with multi-selection
create_multi_select :-
% Create a dialog window
new(Dialog, dialog('Multi-Selection Example')),
% Create a multi-selection
new(Multiselect, menu),
% Add options to the multi-selection
send_list(Multiselect, append, ['Option 1', 'Option 2', 'Option 3', 'Option 4']),
% Enable multiple selection
send(Multiselect, multiple_selection, @on),
% Add the multi-selection to the dialog window
send(Dialog, append, Multiselect),
% Add a button to display selected values
send(Dialog, append, button('Submit', message(@prolog, show_selected, Multiselect))),
% Open the dialog window
send(Dialog, open).
% Predicate to display selected values
show_selected(Multiselect) :-
write(Multiselect),
% Get the selected values from the multi-selection
get(Multiselect, selection, Selections),
forall(member(Selection, Selections),
(
get(Multiselect, member, Selection, Option),
% Answer=Options,
% Display selected values
writeln('Selected options:'),
writeln(Option))).