function newsdemo(x,itemName)
%NEWSDEMO Reuters realtime event callback for RNSE data.
%   NEWSDEMO(X,ITEMNAME) is the Reuters realtime event callback demonstration function
%   used to return RNSE realtime data from the RMDS system to the MATLAB
%   workspace.   X is the return data structure, and ITEMNAME is the name
%   of the returned item.
%
%   For example, the following commands will connect to Reuters, subscribe
%   to the security ABC.N and display the data in realtime in the MATLAB
%   Variable Editor.
%
%   r = reuters('myNS::remoteSession','dIDN_RDF')
%   d = fetch(r,'ABC.N','newsdemo')
%
%
%   The following commands will run the function using data from an
%   existing archive file.
%
%   x = rnseloader('i:\RNS\RNSE.200701-200712.newsrecords.txt','records',100);
%   newsdemo(x)
%
%   See also REUTERS, RTDEMO

%   Copyright 1999-2008 The MathWorks, Inc.
if exist('itemName','var') && ~isempty(itemName)
  x.ItemName = char(itemName);
end

%get number of items
if iscell(x.DSPLY_NAME)
    
  % Code used to backtest data from archive file
  for i = 1:length(x.DSPLY_NAME)
    try
      disp([x.STORY_TIME{i} ': ' x.CO_IDS{i} ': ' x.BCAST_TEXT{i}])
    catch exception %#ok
      %data has no broadcast text
      disp(x.STORY_TIME{i})
    end
  end
else
    
   % Code used to process real time data
   try
    disp([x.STORY_TIME ': ' x.CO_IDS ': ' x.BCAST_TEXT])
  catch exception %#ok
    %data has no broadcast text
    disp(x.STORY_TIME)
  end
end