summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-08 20:28:51 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-08 20:28:51 +0100
commitcae86c996a852150dd81952cbe522dbcab632e98 (patch)
tree761d2a417018027da6d79a00454f949d5ca2bffe
parent80c9333a5987997362753f992b4d5b665033e6b3 (diff)
downloadwbs-cae86c996a852150dd81952cbe522dbcab632e98.tar.gz
wbs-cae86c996a852150dd81952cbe522dbcab632e98.tar.bz2
wbs-cae86c996a852150dd81952cbe522dbcab632e98.zip
pd_client: Use get_code to read only a single byte
-rw-r--r--pd_client.pl7
1 files changed, 6 insertions, 1 deletions
diff --git a/pd_client.pl b/pd_client.pl
index 72742e6..497959a 100644
--- a/pd_client.pl
+++ b/pd_client.pl
@@ -13,6 +13,10 @@ launch(Module, StreamIn, StreamOut) :-
atom_concat('rules/', Module, Path), consult(Path),
do([], StreamIn, StreamOut, Module, [], []).
+% -1 = EOF
+byte_to_atom(-1, e):-!.
+byte_to_atom(A, B):-name(B, [A]).
+
do(e, _, _, _, _, _) :- !.
do(Choice, StreamIn, StreamOut, Module, ModuleState, Hist) :-
call(Module, Hist, ModuleDecision, ModuleState, NewModuleState),
@@ -20,5 +24,6 @@ do(Choice, StreamIn, StreamOut, Module, ModuleState, Hist) :-
loop(StreamIn, StreamOut, Module, NewModuleState, [Choice|Hist]).
loop(StreamIn, StreamOut, Module, ModuleState, Hist) :-
- read_atom(StreamIn, Choice), write(Choice),
+ get_code(StreamIn, ChoiceCode), byte_to_atom(ChoiceCode, Choice),
+ write(Choice),
do(Choice, StreamIn, StreamOut, Module, ModuleState, Hist).