---------- Original Message ----------------------------------
>BTW any preferences for "begin end" layout?
Most definately:
if blah then
begin
DoStuff;
if Blat then
begin
DoSomething;
DoOtherStuff;
end
else
DoSomethingDifferent;
end;
As you can see I totally agree with the other suggestions of using 4 spaces for
indenting - MUCH easier to view the program flow and have been using it for years now.
Also, by placing 'begin' in the same logical indentation as both the 'if' and the
'end', the logical flow shows up better. this goes also better with try/finally
statements
if blah then
try
AttemptSomething;
finally
FreeSomething;
end;
You will have also noted with the first example, that else is ALWAYS on a line of it's
own. Note there is no ELSEIF statement in Pascal. The transfers messy statements like
if x=1 then
Say(1)
else if x=2 then
say(2)
else if x=3 then
say(3)
else say(4)
...bastard of a statement. try the following:
if x=1 then
Say(1)
else
begin
if x=2 then
say(2)
else
begin
if x=3 then
say(3)
else
say(4);
end;
end;
This allows you to see what exactly will happen in any given situation and just as
important, you know which 'if' each 'else' responds to.
Steve
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/