to_sentence Function

public pure function to_sentence(string) result(sentence_string)

Converts character sequence to sentence case (Specification)

Version: experimental

Arguments

TypeIntentOptionalAttributesName
character(len=*), intent(in) :: string

Return Value character(len=len)


Calls

proc~~to_sentence~~CallsGraph proc~to_sentence to_sentence proc~is_alphanum is_alphanum proc~to_sentence->proc~is_alphanum

Contents

Source Code


Source Code

    pure function to_sentence(string) result(sentence_string)
        character(len=*), intent(in) :: string
        character(len=len(string)) :: sentence_string
        integer :: i, n

        n = len(string)
        do i = 1, len(string)
            if (is_alphanum(string(i:i))) then
                sentence_string(i:i) = char_to_upper(string(i:i))
                n = i
                exit
            else
                sentence_string(i:i) = string(i:i)
            end if
        end do

        do i = n + 1, len(string)
            sentence_string(i:i) = char_to_lower(string(i:i))
        end do

    end function to_sentence