pass parameters from java to prolog

16 views
Skip to first unread message

lolo lolo

unread,
Mar 27, 2016, 1:05:36 PM3/27/16
to SWI-Prolog
I have the code below using swi Prolog and I made a interface using jframe in netbeans.

In this jframe I have textbox for answer and another textbox for grade.i want take answer from textbox and pass to start predicate in prolog to process answer. Can anyone tell me how I can do that? The only thing that I know is how to call predicate.

start(Answer,Total_grade):-
Question1 = "Define computer?",
Word_list1 = ["software","operatingsystem"],
Word_list2 = ["hardware","tools"],
Msg = "Write your answers ",
write(Question1),nl,
write(Msg),nl,nl,
read(Answer),
string_lower(Answer,Low_answer),
split_string(Low_answer," ,.()-_"," ,.()-_", Answer_in_list),
find(Answer_in_list,Word_list1,Grade1),
find(Answer_in_list,Word_list2,Grade2),
Total_grade is Grade1 + Grade2,
nl,write("Your grade is : "), write(Total_grade),nl.
Reply all
Reply to author
Forward
0 new messages