Your anonymity is guaranteed (Unless you explicitly permit me to name you and/or link to a site or something).
Please note that there was a syntax problem in the original snippet, and I have indicated that below. I suggest that unless Paul instruct us otherwise, we take out the semi-colon after the end on that line.
try
if ConditionA then
Code(1)
else if ConditionB then
if ConditionC then begin
if ConditionD then
code(2);
code(3);
end; // I assume this semi-colon has to go
else if ConditionE then begin
code(4);
morecode('X');
if ConditionF then
code(5)
else if ConditionG then
code(6);
end else begin
code(7);
morecode('Y');
end;
finally
code(8);
end;
Hmmm, comments system doesn't want to allow a pre tag, so I don't think my indentation is going to be preserved, but I think the indentation should be clear even if it does get lost.
ReplyDeleteSo here goes nothing....
procedure WhenC;
begin
if ConditionD then
code(2);
code(3);
end;
procedure WhenE;
begin
code(4);
morecode('X');
if ConditionF then
code(5)
else if ConditionG then
code(6);
end;
begin
try
if ConditionA then
Code(1)
else if NOT ConditionB then
EXIT;
if ConditionC then
WhenC
else if ConditionE then
WhenE
else
begin
code(7);
morecode('Y');
end;
finally
code(8);
end;
end;
Incidentally, Post #2 in my multicast events series is now up if you're interested. With downloadable code!
:)
@Jolyon: could you email me the above rewrite please? I don't want to mangle your indent style :)
ReplyDelete@All: The mentioned semi-colon has to go, or the code won't compile.
@Jolyon: P.S. You introduced a bug in that rewrite.
ReplyDelete