function somui_mlg(name, title, text)
%SOMUI_MLG is a window for showing ASCII text 
%
%  somui_mlg(name, title, text)
%
% ARGUMENTS
%
%  name   (string)  figure's name
%  title  (string)  title for text
%  text	  (cell/string) text to figure, either cell or
%			text file name
%
% SOMUI_MLG(NAME, TITLE, TEXT) displays TEXT or TEXTfile with TITLE 
%   in figure NAME

% Copyright (c) 1997 by the SOM toolbox programming team.
% http://www.cis.hut.fi/projects/somtoolbox/

% Version 1.0beta Jukka 071197 

% see help fgetl how to do this more clever!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

error(nargchk(3, 3, nargin))  % check no. of input args is correct
error(nargchk(0, 0, nargout)) % check no. of output args is correct

origUnits = get(0,'Units');
set(0,'Units','normalized');


% Doen't work well, use scanf instead!!!
if (~iscell(text))
  str = cell(1000,1);
  fid        = fopen(text,'r');
  [A, count] = fread(fid,'char');
  i=0; j=0; k=0; start=1; stop=1;
  for i=1:size(A)
    if (A(i) == 10)
      stop = i-1;
      k = k+1;
      str{k} = char(A(start:stop)');
      start = i+1;
    end;
  end;
  text = cell(k,1);
  for i=1:k
    text{i} = str{i};
  end;
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

tmp = strcat('SOM Toolbox -- ',name);

a = figure('Color',[0.8 0.8 0.8], ...
	'Units','normalized', ...
	'MenuBar','none', ...
	'Name', tmp, ...
	'NumberTitle','off', ...
	'Position',[0.3 0.3 0.47 0.4], ...
	'Tag','somui_mlg', ...
	'WindowStyle','modal');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[0.701961 0.701961 0.701961], ...
	'Position',[0.01 0.12 0.98 0.87], ...
	'Style','frame', ...
	'Tag','fr_main');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'Callback','delete(gcf)', ...
	'BackgroundColor',[0.701961 0.701961 0.701961], ...
	'Position',[0.8 0.01 0.19 0.1], ...
	'String','Close', ...
	'Tag','pb_close');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[0.8 0.8 0.8], ...
	'HorizontalAlignment','left', ...
	'FontWeight','bold', ...
	'Position',[0.02 0.9 0.96 0.08], ...
	'String', title, ...
	'Style','text', ...
	'Tag','st__title');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'FontName','Courier', ...
	'Max', 2, ...
	'BackgroundColor',[0.9 0.9 0.9], ...
	'HorizontalAlignment','left', ...
	'Position',[0.02 0.13 0.96 0.76], ...
	'String', text, ...
	'Style','listbox', ...
	'Value',[], ...
	'Tag','lb_info');




