On Thu, 15 Mar 2007 23:23:04 -0700
Gus Wirth <[EMAIL PROTECTED]> wrote:

> Jeff Steinkamp wrote:
> > ----- Original Message ----- 
> > From: "Vincent Snijders" <[EMAIL PROTECTED]>
> > To: <[email protected]>
> > Sent: Thursday, March 15, 2007 19:07
> > Subject: Re: [lazarus] Illegal Expression -- Exit
> > 
> > 
> >> Jeff Steinkamp schreef:
> >>> Anyone know why I might be getting an Illegal Expression on a
> >>> line containing the keyword Exit?
> >>>
> >>> Might there be another way to exit a procedure in the middle of
> >>> the procedure beside using the keyword jump?
> >> Can you post a snippet of code?
> >>
> >> Vincent
> > 
> > This is almost word for word from a Delphi project that performs
> > the same function.  I can replace the Exit with a goto LABEL and
> > place the LABEL at the exit point and it does the same thing, but I
> > really like to stay away from goto's!!!  Too many nightmares from
> > my days of assembly language and I am chasing one of these at work
> > right now.
> > 
> > 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;
> 
> This may be a problem trying to evaluate the call to MessageDlg in
> the _if_ statement. Try breaking it up into a couple of separate
> steps to get a closer look at where the problem might be. Something
> like:
> 
>         if FileExists(fLogFilename) then begin
>           ModalResult:= MessageDlg('File Exists, Overwrite this
> file?',mtWarning,[mbYes,mbNo],0);
> 
>          if (ModalResult = mrNO) then Exit;
>         end; {if}
>         StringGridSaveToFile(loggrid,flogfilename);
> 
> Also, don't you need parentheses around boolean expressions?

The IDE code uses a log "if MessageDlg ... then exit"
statements and boolean exp without parenthesis. I just tried
successfully your code with fpc 2.0.4 and mode objfpc.
What compiler and mode are you using?


Mattias

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

Reply via email to