- #1
Nicolaus
- 73
- 0
How would I go about extracting the 3 substrings delimited by the slashes in the date?
The date is a string in the format "d/m/y"
This subprogram checks if there are at least 2 slashes for correct format, and then, if the format is correct, the program would then extract the day, month, and year substrings delimited by the slashes, which is where I'm stuck.
subroutine checkFormat (date, day, month, year, yes)
character*(*) date, day, month, year
logical yes
integer i, count
do while (count .ge. 0 .and. count .lt. 2)
do i = 1, len(date)
if (date(i:i) .eq. "/") then
count = count + 1
end if
end do
if (count .lt. 2) then
yes = .false.
return
end if
end do
return
end
The date is a string in the format "d/m/y"
This subprogram checks if there are at least 2 slashes for correct format, and then, if the format is correct, the program would then extract the day, month, and year substrings delimited by the slashes, which is where I'm stuck.
subroutine checkFormat (date, day, month, year, yes)
character*(*) date, day, month, year
logical yes
integer i, count
do while (count .ge. 0 .and. count .lt. 2)
do i = 1, len(date)
if (date(i:i) .eq. "/") then
count = count + 1
end if
end do
if (count .lt. 2) then
yes = .false.
return
end if
end do
return
end