ispunct Function

public elemental function ispunct(ch) result(res)

NAME

 ispunct(3f) - [M_strings:COMPARE] returns .true. if character is a
 printable punctuation character
 (LICENSE:PD)

SYNOPSIS

elemental function ispunct(onechar)

 character,intent(in) :: onechar
 logical              :: ispunct

DESCRIPTION

 ispunct(3f) returns .true. if character is a printable punctuation
 character

OPTIONS

onechar  character to test

RETURNS

ispunct  logical value returns true if character is a printable
         punctuation character.

EXAMPLE

Sample program:

 program demo_ispunct
 use M_strings, only : ispunct
 implicit none
 integer                    :: i
 character(len=1),parameter :: string(*)=[(char(i),i=0,127)]
    write(*,'(20(g0,1x))')'ISPUNCT: ', &
    & iachar(pack( string, ispunct(string) ))
    write(*,'(20(g0,1x))')'ISPUNCT: ', &
    & pack( string, ispunct(string) )
 end program demo_ispunct

Results:

ISPUNCT:  33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 58 59 60 61
62 63 64 91 92 93 94 95 96 123 124 125 126
ISPUNCT:  ! " # $ % & ' ( ) * + , - . / : ; < =
> ? @ [ \ ] ^ _ ` { | } ~

AUTHOR

 John S. Urban

LICENSE

 Public Domain

Arguments

Type IntentOptional Attributes Name
character, intent(in) :: ch

Return Value logical


Contents

Source Code


Source Code

elemental function ispunct(ch) result(res)

! ident_74="@(#) M_strings ispunct(3f) true if a printable punctuation character (isgraph(c)&&!isalnum(c))"

character,intent(in) :: ch
logical              :: res
   select case(ch)
   case (char(33):char(47), char(58):char(64), char(91):char(96), char(123):char(126))
     res=.true.
!  case(' ','0':'9','A':'Z','a':'z',char(128):)
!    res=.true.
!  case(char(0):char(31),char(127))
!    res=.true.
   case default
     res=.false.
   end select
end function ispunct