Topic: String Index function
Was having difficulty with writting a program dealing with lots of character string manipulation. After digging around I narrowed it down to the following behavior. Perhaps I am missing something but the following seems to indicate a problem in the index function. Can someone please assist? running Build 3177
program testindex
implicit none
character(len=30) :: myString
character(len=20) :: testString
myString = 'This is a test'
testString = 'test'
testString=adjustL(testString)
if(index(myString, testString) == 0)then
print *, 'test is not found'
else
print *, 'test is found at index: ', index(myString, testString)
end if
end program testindex
output is:
test is found at index: 11
Result as expected however if you recompile but change len=20 to len =21 for teststring
i.e.
program testindex
implicit none
character(len=30) :: myString
character(len=21) :: testString
myString = 'This is a test'
testString = 'test'
testString=adjustL(testString)
if(index(myString, testString) == 0)then
print *, 'test is not found'
else
print *, 'test is found at index: ', index(myString, testString)
end if
end program testindex
output is:
test is not found