From cae86c996a852150dd81952cbe522dbcab632e98 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 8 Nov 2012 20:28:51 +0100 Subject: pd_client: Use get_code to read only a single byte --- pd_client.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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). -- cgit