:- module(wc_demo, [ age/1, flag_table/0 ]). :- use_module(library(http/html_write)). :- reexport(library(webconsole)). /** Webconsole demo Very simple webconsole demo. To use, load this file, start the webconsole using the command below and call one of the public predicates. == ?- wc_start. == */ %% age(-Age) % % Ask the user how old s/he is. age(Age) :- wc_ask( [ age(Age, between(0,120)) ], [ p(['How old are you? ', input([name(age)])]) ]). %% flag_table % % Show a table with all Prolog flags flag_table :- findall(Flag-Value, current_prolog_flag(Flag,Value), Pairs), keysort(Pairs, Sorted), wc_html(table(class(flags), [ tr([th('Flag'), th('Value')]) | \rows(Sorted) ])). rows([]) --> []. rows([H|T]) --> row(H), rows(T). row(Flag-Value) --> html(tr([td(class(flag), Flag), td(class(value), '~q'-[Value]) ])).