SRL Archive - RS3 Help

If...then loop problems


3Garrett3

2014-09-12 12:57:06

Hi folks.

Apparently I'm old and don't know the new changes with Lape, but say I have the code:


function Win() : Boolean;
begin
Result := True;
if Result then
Writeln('win');
else
Writeln('not win');
end;

Unless I've horribly forgotten what used to work, this should compile. Now I'm getting "Error: Found unexpected token "else", expected "End" at line X"

What am I doing wrong here? Using RC3 and associated SRL file (from Olly's .zip).

masterBB

2014-09-12 13:06:08


function Win() : Boolean;
begin
Result := True;
if Result then
Writeln('win')
else
Writeln('not win');
end;

It is either:

if a then
begin
Writeln('win');
end;

if not(a) then
begin
Writeln('win');
end;

Or

if a then
begin
Writeln('win');
end else
begin
Writeln('not win');
end;

Or

if a then
Writeln('win')
else
Writeln('not win');

3Garrett3

2014-09-12 13:08:23

So semi colons broke me?

masterBB

2014-09-12 13:12:24

In both pascalscript and lape the if-statement ends with a semicolon. if-else is one statement, it needs one semicolon.

3Garrett3

2014-09-12 13:23:49

From: masterBB
In both pascalscript and lape the if-statement ends with a semicolon. if-else is one statement, it needs one semicolon.


This is very awkward…

Thanks for the refresher!

slacky

2014-09-12 13:44:55

From: 3Garrett3
…

IF-STATEMENT
there is no looping… "while", "for" and "repeat" repeats some piece of code, and so they are referred to as loops, but "if" is just a conditional check, and it's body is only executed if the condition is met, it does not loop until the condition is no longer true.

3Garrett3

2014-09-12 14:21:32

From: slacky
IF-STATEMENT
there is no looping… "while", "for" and "repeat" repeats some piece of code, and so they are referred to as loops, but "if" is just a conditional check, and it's body is only executed if the condition is met, it does not loop until the condition is no longer true.


Yeah but you knew what I meant! Trying to shake the rust off over here ;)