; Pre-count the number of words in .txt file to avoid using ReDim
; Quick way of counting words in a .txt files to avoid using Redim for each new entry, if it doesn't end in an #LF$, it increases in one word count
;
; V1.0 - 22/FEB/2024
;
Procedure words_missing_in_master_wordlist_import_and_process_pre_count_words_in_file(file$)
Debug "file$:"+file$
; Load the .txt file
ReadFile(5,file$)
ReadStringFormat(5)
t$=ReadString(5,#PB_UTF8|#PB_File_IgnoreEOL)
CloseFile(5)
; Convert to Unix
ConvertStringToUnix(t$)
; Count number of words
counter=CountString(t$,#LF$)
If Right(t$,1)<>#LF$ : counter+1 : EndIf
Debug "counter:"+Str(counter)
; Return the number of words
ProcedureReturn counter
EndProcedure
; More Information failed ReadFile(5,file$)
file$="/tmp/Ogre.log"
For i=1 To 1000
If 0=ReadFile(5,file$)
Debug "file$:"+file$
Debug FileSize(file$)
Debug FormatDate("%hh %mm %ss %dd %ii %yyyy",GetFileDate(file$,#PB_Date_Created))
Debug CheckFilename(file$)
Debug Hex(GetFileAttributes(file$)) ;FFFFFFFFFFFFFFFF for Error
End
EndIf
rsf=ReadStringFormat(5)
If rsf=#PB_UTF16BE Or rsf=#PB_UTF32 Or rsf=#PB_UTF32BE
Debug File$+" ReadStringFormat:"+Str(rsf)
End
EndIf
t$=ReadString(5,#PB_UTF8|#PB_File_IgnoreEOL)
If Len(t$)=0
Debug file$+" Error ReadString"
Debug FileSize(file$)
End
EndIf
CloseFile(5)
Next
One more question: Is there a CreateThread in your source file?
; More Information failed ReadFile(5,file$)
file$="/tmp/Ogre.log"
For i=1 To 1000
If 0=ReadFile(5,file$)
Debug "file$:"+file$
Debug FileSize(file$)
Debug FormatDate("%hh %mm %ss %dd %ii %yyyy",GetFileDate(file$,#PB_Date_Created))
Debug CheckFilename(file$)
Debug Hex(GetFileAttributes(file$)) ;FFFFFFFFFFFFFFFF for Error
End
EndIf
rsf=ReadStringFormat(5)
If rsf=#PB_UTF16BE Or rsf=#PB_UTF32 Or rsf=#PB_UTF32BE
Debug File$+" ReadStringFormat:"+Str(rsf)
End
EndIf
t$=ReadString(5,#PB_UTF8|#PB_File_IgnoreEOL)
If Len(t$)=0
Debug file$+" Error ReadString"
Debug FileSize(file$)
End
EndIf
CloseFile(5)
Next
One more question: Is there a CreateThread in your source file?