function attachgrabber (grabbernum, cb)
%
% IVCCLIB: Intel Video Capture Card Library
% Written by Jeff Norris, jnorris@alum.mit.edu
%
% File: attachgrabber.m
%
% Description: This function is what the user calls from Matlab's
% command line to start his system.  When this command is called,
% an observer is created, and images are passed into the callback with
% the name contained in cb.  
%

if ~(ischar(cb))
  disp('cb must be a string, the name of a valid callback function');
  return
end

try
eval(strcat(cb,'(-1)'));
catch
disp('IVCCLIB has detected an error in your callback code:')
disp(lasterr)
return
end

try
m_observer(grabbernum, cb);
catch
disp('If this is the first time youve started IVCCLIB this Matlab')
disp('session, dont panic.  Simply run your command again and you')
disp('wont see this message again.  However, if this isnt your')
disp('first time running an IVCCLIB program this Matlab session, then')
disp('unfortunately, IVCCLIB has encountered a FATAL ERROR.')
disp('You will not be able to capture video until you restart Matlab.')
lasterr
end
