IF THEN ELSE

At this time it is only one Syntax of IF  / THEN / ELSE / (ELSES) / END IF allowed:

IF x=y THEN
  {your Code}
END IF

and

IF x=y THEN
  {your Code}
  {your Code}  ............ so many rows if you want
ELSE
  {your Code}
  {your Code}  ............ so many rows if you want
END IF

IF x=y THEN
  {your Code}
  {your Code}  ............ so many rows if you want
ELSES
  {your Code}  ............  only one row  and no END IF

When you forgot the THEN, BasPas put them on the end for you.

BASIC Source:

Pascal Source:

BEGIN
DIM x as Integer
DIM y as Integer
DIM z as Integer
DIM a as Integer

x = 10
y = 10
z = 5
a = 6
IF (x = y) and (z < a) THEN
    a = z + y
    ? a

ELSE
    ? 'This would never be written!'
END IF

END.

 

 

VAR
x  :  Integer;
y  :  Integer;
z  :  Integer;
a  :  Integer;

BEGIN

x := 10;
y := 10;
z := 5;
a := 6;
IF (x = y) and (z < a) THEN
   BEGIN
        a := z + y;
        Writeln ( a);
   END
ELSE
   BEGIN
        Writeln ( 'This would never be written!');
   END;

END.
 

generates this: ^