/* Sample interface file This interface was designed to use most of the interface driver and to make definitions in Prolog. It has no knowledge involved, although it could be added after a knowledge base was compiled. The files involved are: SAMPLE.PRO SAMPLE.KBS SAMPLE.HLP CLOCK.PRO To build the system you consult this file in the listener or from the file menu, and then in the listener type the goal ?- make_cons. to create the consultation frames. The linker is then used to define a loader, a consultation instance and a system description, and to define a build tree with one Prolog node called CLOCK and an automatically generated help node. To get the CLOCK node, page down from the top of the tree and select CLOCK as the name; then page down again selecting any other name. The help nodes are added by the help option. The saved knowledge-base SAMPLE.KBS contains all this information. To build the other needed files, go to the linker and select the Test option on the build menu. This uses the help compiler to make a help file, and then builds the other modules as PRM files. The help file is irrelevant. Test the system by selecting Go from the Debug menu. */ make_interface(User) :- icreate(User,primary), iclassify(User,user), make_keyboard(k), iset(User,default_keyboard,value,k), make_inform(inf), iset(User,inform_handler,value,inf), !,trimstacks, make_help(h), iset(User,help_system,value,h), make_query(q), iset(User,query_handler,value,fs), make_window(sw,1,80,0,0,white on magenta,none," Example interface",p), iset(User,screen,value,[sw,keys,mssg,hw,err,mnu,qy,fw,mb]), !,trimstacks, make_how(hx), make_advice(a), iset(User,advice_handler,value,a), iset(User,how_system,value,hx). ?- create_method(u_start,(method(u_start,_,_,_,_) :- msg(fs:initialise,chain,[l],[],_), msg(f:browse,chain,[l],foo,_))). make_help(H) :- icreate(H,primary), iclassify(H,help), make_window(hw,15,60,5,10,bright white on cyan,all,"",t), iset(H,window,value,hw), make_query_2(q2), iset(H,query_handler,value,q2), make_vk, iset(hw,view_keyboard,value,vk). make_inform(I) :- make_window(mssg,1,80,23,0,black on white,none,"",h), icreate(I,primary), iclassify(I,inform), iset(I,inform_window,value,mssg). make_loader(Load) :- icreate(Load,system), iclassify(Load,loader). ?- create_method(dummy,(method(dummy,_,_,_,_))). make_cons :- make_interface(u), fset(this_consultation,user_interface,value,u), make_window(keys,1,80,24,0,bright yellow on blue,none,"",p), make_form(f), make_form_2(f2), make_menu(m), make_loader(l), iset(l,system_description,value,s(foo,"sample.sav",foo)), iset(this_consultation,loader,value,l), iset(this_consultation,start,method,u_start), iset(this_consultation,restart,method,u_start), icreate(e,primary), iclassify(e,error_handler), iset(u,error_handler,value,e), make_window(err,15,30,8,40,black on red,all,"",t), iset(e,error_window,value,err), iset(err,view_keyboard,value,vk), icreate(int,primary), iclassify(int,interrupt), iset(u,break_handler,value,int), make_window(tr,10,60,5,10,cyan on blue,all,"",t), iset(this_consultation,trace_window,value,tr). clear_instances :- instance(I),idelete(I),fail. clear_instances. make_query(Q) :- icreate(Q,primary), iclassify(Q,query), make_window(mnu,15,15,5,50,black on red,all,"",t), iset(Q,menu_window,value,mnu), iset(mnu,menu_keyboard,value,qk), make_window(qy,5,60,18,5,magenta on yellow,all,"",t), make_qk, iset(qy,keyboard,value,qk), iset(Q,query_window,value,qy), iset(Q,input_echo,value,qy), icreate(if,primary), iclassify(if,input_formatter), iset(Q,format_in,value,if), iset(Q,format_out,value,of), icreate(y,primary), iclassify(y,why), iset(y,window,value,hw), iset(Q,why_handler,value,y), iset(u,why_system,value,y). make_query_2(Q) :- icreate(Q,primary), iclassify(Q,query), make_window(mnu2,15,15,5,50,black on red,all,"",t), iset(Q,menu_window,value,mnu2), iset(mnu2,menu_keyboard,value,k), iset(Q,query_window,value,qy), iset(Q,input_echo,value,qy), iset(Q,format_in,value,if), iset(Q,format_out,value,of), iset(Q,why_handler,value,y). make_form(F) :- icreate(F,primary), iclassify(F,form), iset(F,background,value,[text("Tony's form")]), iset(F,fields,value, [field(3,3,8,ir,ir,l,bar1), field(5,3,8,ir,ir,r,bar2), field(7,3,8,ir,ir,c,bar3), field(7,20,8,fixed,ir,c,bar4)]), icreate(of,primary), iclassify(of,output_formatter), iset(F,format_out,value,of), make_window(fw,9,80,3,0,yellow on green,none,"",t), iset(fw,keyboard,value,qk), iset(F,window,value,fw), iset(F,current_instance,value,foo), fcreate(fooclass,primitive), icreate(foo,primary), iclassify(foo,fooclass), icreate(fs,primary), iclassify(fs,form_schedule), iset(F,form_scheduler,value,fs), make_bk, iset(F,browse_keyboard,value,bk), iset(F,why_handler,value,y), iset(F,query_window,value,qy), iset(F,menu_window,value,mnu), iset(F,format_in,value,if), iset(fs,formlist,value,[f,f2]), iset(fooclass,bar1,screen,screen(f,0)), iset(fooclass,bar2,screen,screen(f,1)), iset(fooclass,bar3,screen,screen(f,2)), iset(fooclass,bar1,input_type,[30,40,50,60]), iset(fooclass,bar1,question,"What is the value of bar1? "), iset(fooclass,bar2,question,"What is the value of bar2? "), iset(fooclass,bar3,question,"What is the value of bar3? "), iset(fooclass,bar2,help,"bar2_help"). make_form_2(F) :- icreate(F,primary), iclassify(F,form), iset(F,background,value,[text("Steve's form")]), iset(F,fields,value, [field(3,40,8,ir,ir,l,bar1), field(5,40,8,ir,ir,r,bar2), field(7,40,8,ir,ir,c,bar3), field(7,60,8,fixed,ir,c,bar4)]), iset(F,format_out,value,of), make_window(fw2,9,80,3,0,cyan on green,none,"",t), iset(fw2,keyboard,value,qk), iset(F,window,value,fw2), iset(F,current_instance,value,quux), icreate(quux,primary), iset(F,form_scheduler,value,fs), iset(F,browse_keyboard,value,bk), iset(F,why_handler,value,y), iset(F,query_window,value,qy), iset(F,menu_window,value,mnu), iset(F,format_in,value,if), iset(quux,bar1,screen,screen(f2,0)), iset(quux,bar2,screen,screen(f2,1)), iset(quux,bar3,screen,screen(f2,2)), iset(quux,bar1,input_type,[30,40,50,60]), iset(quux,bar1,question,"What is the qvalue of bar1? "), iset(quux,bar2,question,"What is the qvalue of bar2? "), iset(quux,bar3,question,"What is the qvalue of bar3? "), iset(quux,bar2,help,"quux_bar2_help"). make_menu(M) :- icreate(m,primary), iclassify(m,menu), example(X), iset(m,menu_structure,value,X), iset(m,dimensions,value,2), make_window(mb,1,80,1,0,red on black,none,"",t), iset(m,menubar,value,mb), iset(m,help,value,mssg), iset(m,keyboard,value,k). make_bk :- fcreate(kb2,keyboard), fset(kb2,keytable,value, foo( k(function(10),true,done_browsing), k(function(1),msg(this_consultation:user_interface:help_system:help,chain,[l],[],_),continue), k(function(9),bell,continue), k(function(2),msg(f:edit_selected_field,chain,[l],[],_),continue), k(function(3),(msg(m:select,chain,[l],[],Sel), obey(Sel)),continue), k(function(4), (getv(fs:current_form:selected_field,chain,[l],K), getv(fs:current_form:current_instance,chain,[l],I), getv(fs:current_form:fields,chain,[l],L), get_elt(K,L,field(_,_,_,_,_,_,Slot)), msg(hx:explain_how_value,chain,[l],I:Slot,_)), continue))), fset(kb2,keyline,value,"F1 help F2 change F3 menu F4 how F9 bell F10 quit"), icreate(bk,primary), iclassify(bk,kb2). make_qk :- fcreate(kb3,keyboard), fset(kb3,keytable,value,foo( k(function(1),msg(this_consultation:user_interface:help_system:help,chain,[l],[],_),continue), k(function(3),msg(y:explain_why,chain,[l],[],_),continue)) ), fset(kb3,keyline,value,"F1 help F3 why"), icreate(qk,primary), iclassify(qk,kb3). make_vk :- fcreate(kb4,keyboard), fset(kb4,keytable,value,foo(k(_,true,done_viewing))), fset(kb4,keyline,value,"Press any key to continue"), icreate(vk,primary), iclassify(vk,kb4). make_ak :- fcreate(kb5,keyboard), fset(kb5,keytable,value, foo( k(function(1), msg(this_consultation:user_interface:help_system:help,chain,[l],[],_), continue), k(function(4), (getv(a:current_advice,chain,[l],Token), msg(hx:explain_how_advice,chain,[l],Token,_)),continue), k(function(10),true,done_advising))), fset(kb5,keyline,value,"F1 help F4 how F10 exit"), icreate(ak,primary), iclassify(ak,kb5). example(foo(t("System ",65,m(8,5,foo(t("Shell",65,a,"Go to DOS"), t("Calc",66,b,"Pocket calculator"), t("Clock",67,c,"Time and date"))),"DOS, Calculator, Clock",1), t("Query ",66,m(8,5,foo(t("foo",68,d,"Query foo:bar2"), t("quux",69,e,"Query quux:bar2"), t("F",70,f,"HELP F"))),"HELP BAR",11), t("Advice ",67,m(8,5,foo(t("Adv1",71,g,"Jump"), t("Adv2",72,h,"Boil"), t("Recap",73,i,"Recap"))),"Get advice",21))). ?- state(output_module,_,userframes). ?- state(input_module,_,userframes). obey(a) :- command. obey(b) :- calculator(3,3). obey(c) :- clock(5,5). obey(d) :- msg(fs:query,chain,[l],foo:bar2+y,Val),setv(foo:bar2,chain,[l],Val). obey(e) :- msg(fs:query,chain,[l],quux:bar2+yy,Val),setv(quux:bar2,chain,[l],Val). obey(g) :- msg(a:advise,chain,[l],"Prolog"+"Use Prolog-2!"+l,_). obey(h) :- msg(a:advise,chain,[l],"Advisor-2"+"Use Advisor-2!"+l,_). obey(i) :- msg(a:recap,chain,[l],[],_). ?- state(output_module,_,common). ?- state(input_module,_,common). make_advice(A) :- icreate(A,primary), iclassify(A,advice), make_window(aw,15,60,5,10,bright white on cyan,all,"",t), iset(A,window,value,aw), iset(A,query_handler,value,q), make_ak, iset(aw,view_keyboard,value,ak). make_how(H) :- icreate(H,primary), iclassify(H,how), iset(H,window,value,hw).