General information
Category:
Coding, syntax & commands
Hi all-
I haVE THIS PIECE OF CODE THAT IS NOT WORKING? IT IS SUPPPOSE TO GIVE ME A THE BOOK NUMBER AND ALL THE CHAPTER IN THAT BOOK. THERE ARE 12 BOOKS AND BETWEEN 12 AND 30 CHAPTERS IN EACH BOOK
THANKS.
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)
ENDFUNC
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only