function [tnext,evt_nbr] = pull_evt()
%
%  This routine retrieves the next event from the event calendar
%    tnext is the next event time
%    evt_nbr is the next event number
%
%  We start by checking whether the event calendar is empty
%  If so, we return -1 in both arguments
%
global evt_cal
if prod(size(evt_cal)) == 0,
  tnext = -1;
  evt_nbr = -1;
  return
end
%
%  The event calendar wasn't empty, hence we can retrieve the first
%  event from the event calendar
%
[n,m] = size(evt_cal);
tnext = evt_cal(1,1);
evt_nbr = evt_cal(1,2);
%
%  Compact the event calendar
%
if n > 1,
  evt_cal = evt_cal(2:n,:);
 else
  evt_cal = [];
end
%
return