SRL Archive - OSR Help

End Else


Death12652

2010-05-16 21:24:46

I have a procedure that has a If, Then, end else statement. Is it possible to do another end else. Like this…


If Then
begin
end else
end else

Or is there something like that?

senrath

2010-05-16 21:28:19

Sort of. You'd have to do this:
if .. then
begin
...
end else if ..
begin
...
end else
begin
...
end;

You'd use else if (something) for each one save the last.

Death12652

2010-05-16 21:35:30

oh thanks

Sex

2010-05-16 21:48:06

No, you don't.
program New;
var
wat : integer;
begin
wat := 2;
if wat = 0 then
writeln('Wat is zero.')
else if wat = 1 then
writeln('Wat is one')
else if wat = 2 then
writeln('Wat is two.');
end.

i luffs yeww

2010-05-16 22:04:49

^ I think he was only saying that because death might not understand that single line if..then/others (:p lazy) don't need a begin end. :3

aran armath

2010-05-17 01:11:50

From: Sex
No, you don't.
program New;
var
wat : integer;
begin
wat := 2;
if wat = 0 then
writeln('Wat is zero.')
else if wat = 1 then
writeln('Wat is one')
else if wat = 2 then
writeln('Wat is two.');
end.


Think thats easier to follow though. Btw great example.

Sex

2010-05-17 01:14:24

If you are going to nest a begin and end block, just add a begin and end under the else if; otherwise, leave out the semicolon after the line.