Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

SWI Prolog: redirect java console content to UI jframe

 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a prolog file (Expert System) that I consult from Java using Jpl libraries (org.jpl7.*) and I have an UI using jframe where I want to show the output of prolog's queries.when consult prolog file in netbeans,read() predicate runs in console java;i want run in jtextarea in interface.Can anyone tell me how I can do that?

In this UI I have jtextarea for answer and another jtextarea for grade. This is prolog code using swi prolog:
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.

This is netbeans code:
String t1="consult('C:/Users/user/Desktop/prolog/s.pl')";
Query q1=new Query(t1);
Boolean t=q1.hasSolution();
String c1="start(Answer,Total_grade)";
Query c=new Query(c1);
Term f2=c.oneSolution().get("Total_grade");
String b2=f2.toString();
jTextArea2.setText(b2);
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic