<<<< snip "Fortran or C" message in comp.lang.fortran >>>
well, the basic idea is to run though a file and record any word
fitting a
particular criterion i.e: in html :
<.... "keywords" , contents="contentsA , contentsB, ...">
so here I have to look for "<" and the corresponding ">" because,
in between, is the reserved word giving me the nature of "contentsA"
etc...
I then have to find the starting point to the keywords list, read them
one
by one and save them in an array.
Once this is done I have to scan through the entire file, avoiding
everything that's html (so reading only the text) and look for those
words
I saved (the keywords here).
This process is to be repeated for all types of text used to qualify a
text
file (keywords, title, author, that kind of things).
So obviously a subroutine is going to be used with criterion-dependent
arguments.
word, giving its position. But this is very simple since I specify the
word
I am looking for within the code. Now I wish to save a number of words
whose length and number I do not know, in an array (problem with fixed
size
here isn't there ?), knowing only their position via the fact that
they are
"close" to some other word (the reserved word) that I know.
That so far is my problem. I have given _some_ thought to the problem
and
started to wonder if f77 was the best language etc ... you know the
rest.
Also, I noticed that a html file done with dreamweaver has a ^M at the
end
if line, probably carriage return, whilst another html file did not :
the
code worked fine with the second file but not with the first.
Any idea on this one ?
Thanks

contentsB contentsB
<<<<<<<<<<<<<<<<< end message snip >>>>>>>>>>>>>..
Having challenged you to solve my parsing problem and not spotting
you had already posed your own problem, I feel obligated to post
a solution..
I used your message (above) containing 1 occurance of string contentsA
and inserted a couple contentsB at the end.
My program successfully finds the occurances of the 2 keywords
see below:
contentsA
contentsB
1 occurances found for contentsA
2 occurances found for contentsB
! ------------------------
program parse3
implicit none
integer :: i, n, nlen, nkeywords = 0, nfinds(99) = 0
character(30) :: keyword, keywords(99) = ' '
character :: ch
open (1,file='john.txt',form='binary')
do ! read file char-by-char
read (1,end=101) ch
keyword = keyword(2:10) // ch
if (keyword == 'contents="') then ! found start of keywords
keyword = ' ' ; i = 0
do
read (1,end=101) ch
if (ch == ' ') cycle
if (ch == '"') go to 101 ! end of all keywords
i = i+1 ; keyword(i:i) = ch
if (ch /= ',') cycle ! not end of keyword
nkeywords = nkeywords +1
keywords(nkeywords) = keyword(1:i-1) ! save
write (*,*) keyword(1:i-1) ! output keyword
keyword = ' ' ; i = 0 ! reset to ac*** next keyword
end do
end if
end do
101 continue
keyword = ' ' ; i = 0
do
read (1,end=102) ch
keyword = keyword(2:30) // ch ! 30 char text ac***ulator
do n = 1,nkeywords
nlen = len_trim(keywords(n))
if (keyword(30-nlen+1:30) == keywords(n)(1:nlen)) then ! found
text
nfinds(n) = nfinds(n) +1 ! count occurances
end if
end do
end do
102 continue
do n = 1,nkeywords
write (*,'(I3,2A)') nfinds(n), ' occurances found for ',
trim(keywords(n))
end do
end program