Hi all,
I'm trying to write a small app that examines all files in a specified directory and gets a certain value from each file, then output the results somewhere (memo pad at the moment).
I have binary files (Oracle Forms compile .fmx files, in case you're interested) in which I want to search for the word 'Revision' and get the numbers just after the word.
I have tried ReadLn until EOF, but as it's a binary file, I suspect that there is an EOF marker somewhere in the file that stops before the code finds 'Revision'. I used ReadLn to add each line to a string variable (have tried widestring as well) to store the whole file in memory. But when the string is examined (using pos) for the word 'Revision', it does not exist, even though when I open the file in Wordpad (or Notepad) I can clearly see it.
Here's a snippet of code for the ReadLn :
var
fFileIn : TextFile;
sLine : widestring; (or string)
nPos : integer;
bFinished : boolean;
sRevision : string;
begin
.....
bFinished := False;
Repeat
ReadLn(fFileIn, sLine);
sLine := Trim(sLine);
nPos := pos('Revision', sLine);
sRevision := 'Unknown'
IF nPos <> 0 THEN
(get the revision number by looking at the next few chars)
....
bFinished := True;
end; // IF
Until EOF(fFileIn) OR bFinished;
When looking in WordPad, the word 'Revision' is completely on one line (i.e. not split over two lines).
sLine does never contain any part of 'Revision', even though it exists in the file.
I then tried using BlockRead, but that gives the same problem (as well as destroying my local loop variable and other localstring variables).
Here's the blockread snippet of code :
var
fFileIn : File;
sFile : string;
sTemp : char;
begin
.....
Repeat
blockread(fFileIn, sTemp, 1);
sFile := sFile + sTemp;
Until EOF(fFileIn);
Some of the files I am searching through do return the word 'Revision', but some don't, for each version of the code.
I thought about seeing what the value of each character is and dispensing with any below an ASCII value of 65 ('A'), but then I'll be getting rid of the EOF marker, so the code will just loop forever, unless I put some kind of counter in. I did try this with a counter of 5000 (the word appears about 4600), but even that didn't get me anywhere.
Any ideas would be gratefully recieved. (Or the names of any Windows apps that would do this for me!)
I can increase the points depending on the answer. ;)
Thanks,
Grendel.