>LOCAL s1, s2, t_file, t_read, f, nchap, nbook >LOCAL ARRAY aword[2], aword2[2] >s1 = SECONDS() >t_open = FOPEN("family.txt") && open test file WarandPeace.txt >t_read = FREAD(t_open,6000000) && read text file >s2 = SECONDS() >?s2-s1, "Seconds" >?LEN(t_read) >FCLOSE(t_open) > >aword[1] = " the " >aword[2] = " CHAPTER " > > > >f = FILETOSTR("FAMILY.txt") >LOCAL lBook > > >t_sec = 1 >lBook = getbook(f, t_sec) >DO WHILE !EMPTY(lBook) > ?"Book", t_sec > nchap = ALINES(aword, lBook, " CHAPTER ") > FOR x =1 TO nchap > t_andcnt = occurs(" the ", aword[x]) > ?"Chapter ",x, ":", t_andcnt, "occurrences" > ENDFOR > t_sec= t_sec + 1 > lBook = getbook(f,t_sec) >ENDDO > >FUNCTION getbook > lparameters t_text, t_book > LOCAL lsecstart, lsecend, llength, lBook > lsecstart = AT("sec"+LTRIM(STR( t_book)), t_text) > lsecend = AT("sec"+LTRIM(STR( t_book+1)), t_text) > llength = IIF( lsecend=0,LEN( t_text), lsecend- lsecstart) > lbook = SUBSTR( t_text, lsecstart, llength) > RETURN SUBSTR( lbook,LEN("sec"+LTRIM(STR( t_book)))+1) >ENDFUNCAs per your original message on this subject sections are named as 'sec1, sec2,...secN'. Here is a sample text :
0.016 Seconds 413 Book 1 Chapter 1 : 0 occurrences Chapter 2 : 0 occurrences Chapter 3 : 2 occurrences Book 2 Chapter 1 : 1 occurrences Book 3 Chapter 1 : 0 occurrencesSo what's that not working here ?