Jeff Steinkamp wrote:
Jeff Steinkamp schreef:
Anyone know why I might be getting an Illegal Expression on a line containing the keyword Exit?

Can you post a snippet of code?

Compiler fails at the Exit keyword.

procedure TForm1.SaveAsExecute(Sender: TObject);
begin
  savedialog1.InitialDir := HomeDirectory;
  if SaveDialog1.Execute then
   begin
       fLogFileName := Savedialog1.FileName;
       if FileExists(fLogFilename) then
         if MessageDlg('File Exists, Overwrite this 
file?',mtWarning,[mbYes,mbNo],0) = mrNO then Exit;

       StringGridSaveToFile(loggrid,flogfilename);
       fLogHasChanged := false;
       caption := 'Ten-Ten Logging System - ' + flogfilename;

   end;
end;

How about

 procedure TForm1.SaveAsExecute(Sender: TObject);
 begin
   Exit;
 end;

and

 ...
        if FileExists(fLogFilename) then
          Exit;
 ...

and

 ...
        if FileExists(fLogFilename) then
          if mrNO = MessageDlg('File Exists, Overwrite this 
file?',mtWarning,[mbYes,mbNo],0) then Exit;
 ...

If Exit is a variable or field in the local scope, you actually get the 
'illegal expression' error.

When posting this kind of questions, please give not only a code snippet, but also specify your exact compiler version (or svn revision), and include the exact and entire output of the compiler; if it's more than say 10 lines, please put it at the end of your mail. It is also recommended to try to isolate the error in a standalone program; this might even resolve your problem before posting to the list :)
Note that parenthesis are not obligatory here around the boolean expression -- 
this is not C, neither are we dealing with a '(a = b) and (c = d)' construction.

Regards,

Bram

----

program exitdemo;

var
 Exit:boolean;

procedure Foo;
 begin
   Exit;
 end;

begin

 Foo;

end.

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to