Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax errors just have me bumfoozled

Status
Not open for further replies.

rsballard

Technical User
Oct 1, 2002
16
US
3 syntax errors just don't make any sense to me

<--------1st one------------->
Error: Statement expected but expression of type TButton found at the exit statement in:
// open the input file
AssignFile(inF, hypackFileEdit.Text);
Reset(inF);
if IOResult <> 0 then
begin
showmessage('could not open ' + hypackFileEdit.Text + ' for some reason');
CloseFile(inF);
exit; // Won't compile past this point!
end;
This is in
procedure TMainForm.ProcessSrcClick(Sender: TObject);
which is a button click procedure

<---------2nd one--------------->
Error line 192: Incompatable types
Seek(inF, 0); // rewind to start

inF is a File var of type 'TextFile' declared as

var inF, otF, qcF: TextFile;

<---------3rd one--------------->
Error line 216: Incompatible types
// rewind again and find the first 'FIX' record
Seek(inF, 0); //

Any ideas?

Bob
 
I think you need to use a string literal for the file name(such as 'C:\HyPackFileEdit.text').

Also, doesn't reset put you at the beginning of the file? Why do you want to use seek here? I couldn't get seek to work unless I declared the file variable as
inF : File of Byte;

which I found in the help for the seek procedure.
 
Reset closes and then open the file at the beginning. I didn't see any need to go through that but using Seek as shown in help would not work. Help indicates that it will work with any kind of file so...

Anyway, I ended up having to use Reset and I've commented out the if IOResult code so things work. Still a head scratcher.

Bob
 
It turns out I had an button named &quot;exit&quot; on the form that conflicted with the exit function. It's usually something simple isn't it? Still don't know why Seek won't work with 'TextFile' types but Reset is doing the trick for now.

Thanks
Bob
 
Text files might not be files. I've written text file device drivers before--there's no way to seek such a device. Thus the system does not permit seeks of a text file.

If you know it's a standard text file you can cheat. Declare a variable of type File at the same location (use absolute) and seek that file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top