anchor.diff:  	ok -> ok
       end.
   
  -
  -%% nifty interface
  +get_last_event(Handler, Id) ->
  +    Handler ! {self(), get_last_event, {Id}},
  +    receive
  +	R -> string:substr(R, 7, length(R)-7)
  +    end.
  +
  +%% high-level stuff
  +next_event(Handler, Mote) ->
  +    case get_last_event(Handler, Mote) of
  +	not_listened_to ->
  +	    fail;
  +	badid ->
  +	    badid;
  +	updated ->
  +	    next_event(Handler, Mote);
  +	no_event ->
  +	    ok = simulation_step_ms(Handler),
  +	    next_event(Handler, Mote);
  +	E ->
  +	    E
  +    end.
  +
   wait_for_result(Handler, Mote) ->
       wait_for_result(Handler, Mote, 1000).
   
  
positive.code: 	 mote_read/2,
  	 mote_read_s/2,
  	 msg_wait/2,
  	 %% nifty interface
  	 alloc/3,
  	 alloc/4,
  
negative.code: 	{running, _} ->
  	    S = mote_read(Handler, Mote),
  	    NS = Acc++S,
  	    case re:run(NS, "DEBUG.*\n") of
  		{match, [{_, End}]} ->
  		    io:format("~s", [NS]),
  		    ok = simulation_step_ms(Handler),
  		    wait_for_result(Handler, Mote, T-1, Msg, string:substr(NS, End+1));
  		_ ->
  		    case re:run(NS, Msg) of
  			{match, _} ->
  			    NS;
  			nomatch ->
  			    ok = simulation_step_ms(Handler),
  			    wait_for_result(Handler, Mote, T-1, Msg, NS)
  		    end
  	    end;
  	_ -> 
  	    undef
  