Yathosho
27th January 2004 14:20 UTC
Batch File Search
i'm stuck for several hours now, i hope someone here can help me fixing my problem. i have combined two scripts which both work independently. since i combined them, the text-search doesn't work anymore.. and i have no idea why.
Name "FindHello"
OutFile "FindHello.exe"
!include "FileSearch.nsh"
Section -bla
Push $R0
FindFirst $R0 $R1 "C:\*.txt"
AVSAgain:
StrCmp $R1 "" AVSEnd
!insertmacro FileSearch "$R1" "hello"
StrCmp $1 yes 0 +2
MessageBox MB_OK "$1, was found in the file $0 times."
FindNext $R0 $R1
Goto AVSAgain
AVSEnd:
FindClose $R1
SectionEnd
help is highly appreciated!
kichik
27th January 2004 16:00 UTC
FindFirst/FindNext return only the file name, use a full path with FileSearch.
Yathosho
27th January 2004 16:23 UTC
thanks, works now.
when i try searching the attached file for "Convolution", it does not find that. so far it worked on standard .txt and .ini files, not on the attached file.
is there a solution?
Yathosho
27th January 2004 19:49 UTC
..maybe i should add that avs files are basically a text-file, finding the mentioned expression works in any text-editor
kichik
27th January 2004 20:01 UTC
That AVS file is not a normal text file, it has null characters in it. You'd have to read it using FileReadByte.
Yathosho
27th January 2004 20:07 UTC
which is what i did (at least i replaced FileRead with FileReadByte), or do i have to search for a different expression then?
if so, how do i convert my plain-text search strings to work with FileReadByte?
kichik
27th January 2004 20:54 UTC
Just replacing FileRead with FileReadByte is not enough as FileReadByte reads byte by byte and not line by line. You'd need to run FileReadByte in a loop and build a string, converting each byte to a character using IntFmt. I think Afrow UK made an example for this once. I think he even created an archive page that reads a string using FileReadByte.
Yathosho
27th January 2004 21:01 UTC
super, works!