firstclause('This is the first clause of this file'). :- package(gui). :- package(guibuilder). :- package(guievent). main(Applet,_) :- gui(Applet, gridbag, [ fill=both, weightx=1.0, weighty=1.0, button(_, 'code base') ** action(get_codebase(Applet, Info)), button(_, 'document base') ** action(get_documentbase(Applet, Info)), width=remainder, button(_, 'server text file') ** action(get_serverfile(Applet, Info)), weightx=0.0, width=remainder, height=1, label(Info, '', center) ]). get_codebase(Applet, Info) :- applet_getCodeBase(Applet, Codebase), url_toExternalForm(Codebase, Name), label_setText(Info, Name). get_documentbase(Applet, Info) :- applet_getDocumentBase(Applet, Documentbase), url_toExternalForm(Documentbase, Name), label_setText(Info, Name). get_serverfile(Applet, Info) :- applet_getCodeBase(Applet, Base), url_toExternalForm(Base, BaseName), atom_concat(BaseName,'ExamplePrograms/MinervaFeatures/FileFromServer/',Name), atom_concat(Name, 'location.min', Url), ( lookup_serverfile(Url,Clause) -> functor(Clause,Functor,Arity), atom_number(ArityAtom,Arity), atom_concat(Functor,ArityAtom,Text) ; atom_concat('not found - Check URL: ',Url,Text) ), label_setText(Info, Text). lookup_serverfile(Url, Clause) :- catch(read_first_clause(Url, Clause), _, fail), !. read_first_clause(Url, Clause) :- write(open(Url,read,Stream,[url,text,buffered])),nl, open(Url, read, Stream,[url,text,buffered]), read(Stream,Clause), close(Stream).