Get Value from browser element in XPCE prolog

Dear Community,

I have the following problem:

  1. I have two browser windows, in one browser window I want to append elements from the drop-down menu by clicking the button “Add”. With this task I have no difficulties.
  2. After getting several elements I would like to be able to choose one of the elements in the browser window and by clicking another button “Select” get several predefined options, depending on the previous choice, in the second browser window. This is what created troubles for me. From what I’ve found there are some operators, such as: “get”, “dict” and "dict_item. However, as I am new to XPCE and I haven’t found clear examples and I am asking for the help from community. The code is as follows:
my_form :-

new(D, dialog('Main window', size(800, 800))),
    new(H1, dialog_group(' ')),
  
    send(D, append, H1),
	
	new(ServType,  menu(service, cycle)),
    send_list(ServType, append, [abcd, efgh, ijkl, mnop]),
	send(H1, append, ServType),
	
	new(Brow, browser),
	send(H1, append, Brow),
    new(Lb, list_browser),
	send(H1, append, Lb, right),

    send(H1, append, 
         button(add, 
                message(@prolog, add_element, ServType?selection, Lb))),
				
	send(H1, append,
		button(select,
			message(@prolog, add_subelement, ServType?selection, Brow))),	
	
	send(D, open).
    

    add_element(ServType, Lb) :-
        send(Lb, append, ServType).
    	
    add_subelement(ServType, Brow) :-
    	%get(Lb, )
    	ServType == abcd,
    	send_list(Brow, append, [wwww, zzzz, yyyy]);
    	ServType == efgh,
    	send_list(Brow, append, [vvvv, qqqq, uuuu]).
    	
    
    start :- my_form.

The core problem is in this part:

  add_subelement(ServType, Brow) :-
        	%get(Lb, )
        	ServType == abcd,
        	send_list(Brow, append, [wwww, zzzz, yyyy]);
        	ServType == efgh,
        	send_list(Brow, append, [vvvv, qqqq, uuuu]).

Instead of “ServType” I would like to pass the “Lb”, extract the value, check if it corresponds to the set condition and then append some values using “send_list” to the “Brow” browser element.

Thank you for your help!

N.B. I also published this issue on stackoverflow, link: https://stackoverflow.com/questions/62721181/get-value-from-browser-element-in-xpce-prolog

What is the problem? Just pass Lb using the message you add to the select button? I do not recall a limit to the number of arguments you can pass, but if there is it is at least 10.

Thank you very much for your reply! I apologize, I was not clear enough. If I got you right, you propose something like:

send(H1, append,
    		button(select,
 			message(@prolog, add_subelement, ServType?selection, Lb, Brow))),
....
add_subelement(ServType, Lb, Brow) :-
....

But the problem is, how can I extract the value inside the “Brow”, to pass it further. For instance, I have chosen some value in “Lb”, accordingly display the results in the second browser window, like choose “a”, if “a” then “b”, “c”, “d” and then select “b” or “c” or “d” to pass it further. The question is how can I capture the value inside the second browser window, so that I have the full relation chain (“a” -> “b” or “c” or “d”)? Or another example, in first window I select the car brand, like “Renault” in the second window I get some models of “Renault” like “Megan”, “Clio”, etc, then I select, for instance, “Megan”, so I should get kind of related items or “inherited”, so that “Megan” is always “Renault”. Something like (I know it is wrong):

send(H1, append,
    		button(select,
 			message(@prolog, add_subelement, Lb, Brow))),
....
add_subelement(Lb, Brow) :-
Lb.Value == renault,
send_list(Brow, append, [clio, megan]);

Browser and list_browser have a get method selection. That returns a chain of, or a single dict_item object. You can ask that for the key or label.