Logo

Programming-Idioms

History of Idiom 137 > diff from v32 to v33

Edit summary for version 33 by tkoenig:
New Fortran implementation by user [tkoenig]

Version 32

2019-09-27, 13:15:55

Version 33

2019-09-27, 22:58:15

Idiom #137 Check if string contains only digits

Set boolean b to true if string s contains only characters in range '0'..'9', false otherwise.

Idiom #137 Check if string contains only digits

Set boolean b to true if string s contains only characters in range '0'..'9', false otherwise.

Code
b = .true.
do i=1, len(s)
  if (s(i:i) < '0' .or. s(i:i) > '9') then
    b = .false.
    exit
  end if
end do