For Programmers: Free Programming Magazines  


Home > Archive > Fortran > November 2005 > Re: TRIM









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: TRIM
analyst41@hotmail.com

2005-11-17, 9:57 pm

I believe that one can produce a variable length string array (but it
is probably a sun f77 extension)

cat junk.f
character string1*10,string2*8
string1 = 'abcdef '
string2 = 'abcde '
call dummy(string1,mylen(string1))
call dummy(string2,mylen(string2))
stop
end
subroutine dummy(string,n)
character stringarray*1(n),string*(*)
do j = 1,n
stringarray(j) = string(j:j)
enddo
print *,stringarray,n
return
end
function mylen(string)
character string*(*)
do j = len(string),1,-1
if (string(j:j).ne.' ') then
mylen = j
return
endif
enddo
mylen = 0
return
end
f77 junk.f
junk.f:
MAIN:
dummy:
mylen:
a.out
abcdef 6
abcde 5

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com