function status = openvar(name)
%openvar Open a workspace variable for graphical editing.
%   openvar(NAME) edits the array in the base workspace whose name is given
%   in NAME.  NAME must contain a string.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.14 $  $Date: 1998/10/23 21:46:39 $

if strncmp(computer, 'MAC', 3)
  if nargin == 0
    error('Please provide the name of an array to edit.');
  elseif ~isstr(name)
    error('The array name must be a string.');
  elseif evalin('base', ['exist(''' name ''') ~= 1'])
    error(['An array named "' name '" does not exist in the base workspace.']);
  else
    array = evalin('base', name);
    arraySize = size(array);
    if (~isnumeric(array) & ~iscellstr(array) & ~ischar(array))
      error(['Only numeric arrays, cell arrays of strings, and character arrays can be edited graphically.']);
    elseif (ndims(array) > 2)
      error(['Only 2D arrays can be edited graphically.']);
    elseif (iscellstr(array) & (arraySize(1) > 1) & (arraySize(2) > 1))
      error(['Cell arrays of strings must be row or column vectors to be edited graphically.']);
    elseif (ischar(array) & (arraySize(1) > 1))
      error(['Only 1xN character arrays can be edited graphically.']);
    else
      mactools('arrayedit', name);
    end
  end
else
  if nargin == 0
    error('Please provide the name of an array to edit.');
  elseif ~isstr(name)
    error('The array name must be a string.');
  elseif evalin('base', ['exist(''' name ''') ~= 1'])
    error(['An array named "' name '" does not exist in the workspace.']);
  else
    array = evalin('base', name);
    if ~isnumeric(array)
      error(['The array named "' name '" is not numeric.  Only numeric arrays can be edited graphically.']);
    elseif issparse(array)
      error(['The array named "' name '" is sparse.  Only full numeric arrays can be edited graphically.']);
    else
      dims = size(array);
      if(length(dims) ~= 2)
        error(['The array named "' name '" is multidimensional.  Only 2D arrays can be edited graphically.']);
      else
        name = ['array::' name];    % add sentinel to tell Editor that this is an array name
        if strncmp(computer,'PC',2)
          system_dependent('miedit','array', name);
	else
	  if miport ~= 0
	    system_dependent('miedit','array', name);
	  else
	    error('Array editing is unavailable.');
	  end
        end
      end
    end
  end
end



