View Full Version : If...then loop problems
3Garrett3
09-12-2014, 04:57 PM
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
09-12-2014, 05:06 PM
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
09-12-2014, 05:08 PM
So semi colons broke me?
masterBB
09-12-2014, 05:12 PM
In both pascalscript and lape the if-statement ends with a semicolon. if-else is one statement, it needs one semicolon.
3Garrett3
09-12-2014, 05:23 PM
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
09-12-2014, 05:44 PM
...
IF-STATEMENT (http://en.wikipedia.org/wiki/Statement_(computer_science))
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
09-12-2014, 06:21 PM
IF-STATEMENT (http://en.wikipedia.org/wiki/Statement_(computer_science))
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 ;)
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.