C.3.2 Lowercase_Text_Utils Procedure

The main documentation of the Lowercase_Text_Utils Procedure contains additional explanation of this code listing.

  function Lowercase_Text_Utils (String) result(Lowercase)

    ! Input variables.

    type(character,*), intent(in) :: String         ! String to be lowercased.

    ! Output variables.

    type(character,255) :: Lowercase    ! The lowercase version of the string.

    ! Internal variable.

    type(integer) :: letter             ! Loop counter.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ! Verify requirements.

    VERIFY(Valid_State(String),5)          ! String is valid.

    ! Loop through letters, setting lowercase version.

    Lowercase = ' '
    do letter = 1, LEN_TRIM(String)
      if (ICHAR(String(letter:letter)) .InInterval. Majuscules) then
        Lowercase(letter:letter) = &
          CHAR(ICHAR(String(letter:letter)) - Capitalization)
      else
        Lowercase(letter:letter) = String(letter:letter)
      end if
    end do

    ! Verify guarantees.

    VERIFY(Valid_State(Lowercase),5)  ! Lowercase is valid.

    return
  end function Lowercase_Text_Utils



Michael L. Hall