Topic: Simple if then else

Hi Everybody
I know my problem is probably very easy. Im not a programmer but somebody that is trying to learn with My Visual Database.

Ive been trying to work a IF THEN ELSE, and before trying to post here, i googled and googled and googled, but cant find out what I am doing wrong.

Im probably doing multiple things wrong, but I cant seem to figure out this simple problem.

Here is the code

procedure fmClientInfo_Button17_OnClick (Sender: TObject; var Cancel: boolean);  // shortcut button with a path on hard drive
var
       strLink : string;


begin

        strLink := fmMyform.cfDriveLink.text;
        if (strLink = '') then ;
            //begin
                ShowMessage('No link');
           // end;
        else
           //  begin
                OpenURL(fmMyform.cfDriveLink.text);
           //  end;

end;

Any help would be great and any reference books that you recommend (delph ? Turbo Pascal ?)

2 (edited by CDB 2020-02-12 11:19:32)

Re: Simple if then else

Hi Jeffmtl,


You've become confused with the end of line semicolons.

Try the following:

procedure fmClientInfo_Button17_OnClick (Sender: TObject; var Cancel: boolean);  // shortcut button with a path on hard drive
var
       strLink : string;

begin
        strLink := fmMyform.cfDriveLink.text;

        if strLink = '' then   //[color=BLUE]Unlike C, you do not need parentheses for simple statements[/color] 
           
                ShowMessage('No link') // [color=blue]Begin/End is not needed for a single statement, NO [b]; [/b]needed if only one statement after the IF clause[/color].
          
        else
           
                OpenURL(fmMyform.cfDriveLink.text);  //[color=blue] [b];[/b] is needed at this statement[/color]
           
end;

For a reference, you could look up Freepascal.org or Lazarus

On a clear disk you can seek forever