function l4 = s_to_l4 ( s )

%*****************************************************************************80
%
%% s_to_l4() reads a logical value from a string.
%
%  Discussion:
%
%    There are several ways of representing logical data that this routine
%    recognizes:
%
%      False   True
%      -----   ----
%
%      0       1
%      F       T
%      f       t
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 December 2010
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string S, the string to be read.
%
%  Output:
%
%    logical L4, the logical value read from the string.
%
  s_length = length ( s );

  for i = 1 : s_length
    if ( s(i) == '0' | s(i) == 'F' | s(i) == 'f' )
      l4 = false;
      return
    elseif ( s(i) == '1' | s(i) == 'T' | s(i) == 't' )
      l4 = true;
      return
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, 'S_TO_L4 - Fatal error!\n' );
  fprintf ( 1, '  The input string did not contain logical data.\n' );
  error ( 'S_TO_L4 - Fatal error!' );

end
