When I had a C64 back in the days, the only IF/THEN statement we could create in BASIC v2 was just that: IF and THEN.
There was no ELSE, and everything had to be on a single line. It was the only flow control we had back in those days, and it was a severe limitation compared to what we can do with higher level languages today.
Here’s an example:
10 input x 20 if x=1 then print"x is one" : goto 100
Such constructs weren’t very convenient when you wanted to react to anything other than the tested value. Instead you had to write an IF statement for every possible other outcome which could make the code very cluttered with several GOTO statements.
When the Plus/4 came out Commodore added the ELSE statement. It still had to be on the same line as the IF and THEN, but at least we had ELSE as an option:
10 input x 20 if x=1 then print "x is one" : else print "x is not one"
ELSE needs to be on the same line as the IF/THEN statement and separated by a colon.
ELSE was a very handy addition to the BASIC arsenal, but it still didn’t solve the problem that your evaluation had to be cramped into a single line. This was improved on the C128 with the introduction of BEGIN/BEND.
BEGIN and BEND allowed you to execute as many lines of code as you wanted between those statements when a condition was true (or false). Used together with IF, THEN and ELSE it was a very useful thing to have:
10 input x 20 if x=1 then begin 30 print "x is one" 40 print "which is like totally awesome" 50 rem more code here 60 bend : else begin 70 print "x was obviously not one" 80 print "which is a shame" 90 print "but that's life" 100 bend
BEGIN means that everything starting from now until BEND is met will be executed as part of the IF/THEN statement – as many lines of code you like.
When BEND is met the code continues as normal – but we can also use ELSE after a colon on the same line, indicating that this is still part of the first IF/THEN statement. Here we can use BEGIN again for as many lines as we like, until we finish with BEND again.
It was very very cool!
sys 32800,123,45,6 to show these credits (thanks, team!)