Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code not working part2
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Code not working part2
Miscellaneous
Thread ID:
00922340
Message ID:
00922340
Views:
61
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

the programs runs through only once and I get no output. it should run 12 times for the 12 books


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
Map
View

Click here to load this message in the networking platform