The semicolon before else: a support group

Go down

The semicolon before else: a support group

· #1

Hello. My name is demo_dan and I have put a semicolon before else.

pascal
if Ready then
  Start;
else
  Wait;
text
Fatal: Syntax error, ";" expected but "ELSE" found

I have been writing Pascal for a long time. I did it again yesterday.

Re: The semicolon before else: a support group

· #2

Welcome, Dan. You're among friends.

The rule is short: a semicolon separates statements, it does not end them. if … then … else … is one statement, so nothing separates anything in the middle of it.

pascal
if Ready then
  Start
else
  Wait;

The fix is one character. The shame lasts longer.

Read the error message. Then read it again.

Re: The semicolon before else: a support group

· #3

As the beginner here: I did this four times today. I thought it was just me.

Re: The semicolon before else: a support group

· #4

It is never just you. My record is three in one case statement.

Pete · thirty years of begin and end "It compiled on my machine."

Go up

Sign in to reply