  function [err, errmsg] = OsiSetTend(tend,ConNo)
%
% OsiSetTend.m				Set OLGA's simulation simulation end time.   
%
% The calling syntax is:
%
%   err = OsiSetTend(tend,ConNo);
%
% Input:
%   tend:   New simulation (integration) end time. 
%
%
% Copyright (c) 1998 by ABB Corporate Research.
% All Rights Reserved.
%
% $Revision: 1.0, 5/10-1998 by Kjetil Havre$
% $Revision: 1.1, 20/7-2005 by Espen Storkaas, ABB-EOP, included user-defined connection number$ 

  if nargin==1
      ConNo=1;
  end
  if nargin > 2 | nargin==0 
     errmsg = 'OsiSetTend usage: [err, errmsg] = OsiSetTend(tend,ConNo);';
     disp(errmsg);
     err = -1;
     return
  end

  [m,n] = size(tend);
  if m*n ~= 1
     disp('OsiSetTend: using TEND(1,1)');
  end

  [err, msg, ibody, rbody, errmsg] = osmi(ConNo, 'OLGA_SET_TEND', [], tend(1,1), []);

  
