function value = ch_to_num ( ch )

%*****************************************************************************80
%
%% ch_to_num() converts a VIN character to a numeric value.
%
%  Discussion:
%
%    Assumes all characters are digits or capital letters.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    09 September 2022
%
%  Input:
%
%    character CH: the character to be converted.
%
%  Output:
%
%    integer VALUE: the corresponding value.
%
  ch = upper ( ch );
  n = double ( ch );
%
%  Digits.
%
  if ( n <= double ( '9' ) )
    value = n - double ( '0' );
%
%  A through I.
%
  elseif ( n < double ( 'I' ) )
    value = n - double ( 'A' ) + 1;
%
%  J through R
%
  elseif ( n <= double ( 'R' ) )
    value = n - double ( 'J' ) + 1 ;   
%
%  S through Z.
%
  else
    value = n - double ( 'S' ) + 2;
  end

  return
end

