Problem with my split routine I am not understanding
- From: Jeremy <my-first-name@xxxxxxxxxx>
- Date: 28 Dec 2006 17:58:10 GMT
I have the following function:
subroutine split(what, by, into)
implicit none
character(len=*), intent(in) :: what, by
character(len=*), dimension(:), intent(out) :: into
integer :: bpos = 1, pos = 1, idx = 1
do
pos = scan(what(bpos:), by)
if (pos == 0) exit
into(idx) = what(bpos:pos + bpos - 2)
idx = idx + 1
bpos = bpos + pos
end do
into(idx) = what(bpos:)
end subroutine split
To test this, I have:
program SplitTest
uses splitmod
implicit none
character(10), dimension(1:2) :: data
call split('JOHN|DOE', '|', data)
print *, data(1) ! outputs: JOHN
call split('JANE|SMITH', '|', data)
print *, data(1) ! outputs: JANE
end program SplitTest
The problem is that once the array data is filled, it seems to not change.
Any ideas on what I am doing wrong?
Jeremy
.
- Follow-Ups:
- Re: Problem with my split routine I am not understanding
- From: Donald Fredkin
- Re: Problem with my split routine I am not understanding
- From: *** Hendrickson
- Re: Problem with my split routine I am not understanding
- From: Beliavsky
- Re: Problem with my split routine I am not understanding
- Prev by Date: Re: Proper way to return a string
- Next by Date: Re: Proper way to return a string
- Previous by thread: F2003: pass disallowed for procedure pointer components?
- Next by thread: Re: Problem with my split routine I am not understanding
- Index(es):