Update belief with users input values

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Update belief with users input values

Marco
This post has NOT been accepted by the mailing list yet.
Hi,

I am trying to obtain the value of a variable from a Java GUI via an internal action. I am new using Jason, so maybe this is not the way to do it.

My agent code is
/* Initial beliefs and rules */
request(r).

/* Initial goals */
!start.

/* Plans */
+!start : true <- .print("Agent Initialized...");
				  !askUser(Q).
+!askUser(Q) : true <- allCommunicatingAgents.requestQuery(Q);
				   +request(Q);

requestQuery is my internal action.
The execute method of the class requestQuery is the following:

String query = JOptionPane.showInputDialog(new JFrame("Query"),"Hi, ask the knowledge query below:" );
Unifier q = un.clone();
q.unifies(args[0], new StringTermImpl(query));

The result when printing out q is the following:
{_17="value of the string", Q=_17}

After this, if I use another internal action to extract the term of the belief request I obtain:
_18

I understand that
_18 
 is an unnamed variable, how do I deal with it to convert it into a term or maybe a StringTerm?

My goal in the end is to obtain a request from a user to the agent this request is obtain from the user as a string. But how do I update the belief of the agent with this string? Because later I need this agent to be able to send or manipulate this same string.

Thank you for your help.
Marco
Loading...