read_whole_number_indexed Function

public pure function read_whole_number_indexed(string, istart, istop)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string
integer, intent(in) :: istart
integer, intent(in) :: istop

Return Value integer


Calls

proc~~read_whole_number_indexed~~CallsGraph proc~read_whole_number_indexed read_whole_number_indexed proc~get_integer_digit_from_string get_integer_digit_from_string proc~read_whole_number_indexed->proc~get_integer_digit_from_string proc~is_whole_number is_whole_number proc~read_whole_number_indexed->proc~is_whole_number proc~get_integer_digit get_integer_digit proc~get_integer_digit_from_string->proc~get_integer_digit

Called by

proc~~read_whole_number_indexed~~CalledByGraph proc~read_whole_number_indexed read_whole_number_indexed proc~construct_iso8601duration construct_ISO8601Duration proc~construct_iso8601duration->proc~read_whole_number_indexed proc~read_whole_number read_whole_number proc~read_whole_number->proc~read_whole_number_indexed proc~test_read_whole_number_indexed test_read_whole_number_indexed proc~test_read_whole_number_indexed->proc~read_whole_number_indexed interface~iso8601duration ISO8601Duration interface~iso8601duration->proc~construct_iso8601duration proc~parse_date parse_date proc~parse_date->proc~read_whole_number proc~parse_time parse_time proc~parse_time->proc~read_whole_number proc~parse_timezone_offset parse_timezone_offset proc~parse_time->proc~parse_timezone_offset proc~parse_timezone_offset->proc~read_whole_number proc~test_read_whole_number test_read_whole_number proc~test_read_whole_number->proc~read_whole_number proc~construct_iso8601date construct_ISO8601Date proc~construct_iso8601date->proc~parse_date proc~construct_iso8601time construct_ISO8601Time proc~construct_iso8601time->proc~parse_time proc~test_parse_date test_parse_date proc~test_parse_date->proc~parse_date proc~test_parse_time test_parse_time proc~test_parse_time->proc~parse_time proc~test_parse_timezone_offset test_parse_timezone_offset proc~test_parse_timezone_offset->proc~parse_timezone_offset interface~iso8601date ISO8601Date interface~iso8601date->proc~construct_iso8601date interface~iso8601time ISO8601Time interface~iso8601time->proc~construct_iso8601time proc~test_construct_iso8601time test_construct_ISO8601Time proc~test_construct_iso8601time->proc~construct_iso8601time

Source Code

   pure integer function read_whole_number_indexed(string, istart, istop)
      character(len=*), intent(in) :: string
      integer, intent(in) :: istart
      integer, intent(in) :: istop
      integer, parameter :: BASE=10
      integer :: n
      integer :: i
      integer :: place_value
      integer :: digit_value

      read_whole_number_indexed = INVALID

      ! Check indices
      if((istart < 1) .or. (istart > istop) .or. (istop > len(string))) return

      ! Convert characters from string, last to first, to integers,
      ! multiplies by place value, and adds
      place_value = 1
      n = 0
      do i= istop, istart, -1
         digit_value = get_integer_digit_from_string(string, i)
         if(is_whole_number(digit_value)) then
            n = n + digit_value * place_value
            place_value = place_value * BASE
         else
            n = INVALID
            exit
         end if
      end do
      read_whole_number_indexed = n
   end function read_whole_number_indexed