The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
End if
#8
Well, after *SEVEN* years :oops: (sorry), what I though impossible became possible :!:

I finally achieved it: ZX Basic now allows omitting the trailing END IF for single line IF THEN sentences (like Sinclair BASIC). Moreover, it also allows ELSE in the same line. This can lead to really strange (but valid) code:
Code:
10 IF a < b THEN LET a = a + 1: IF a < c THEN a = a + c: ELSE a = a - 1: LET c = c - 1: ELSE b = b + c
is now *VALID* and it's equivalent to:
Code:
IF a < b THEN LET a = a + 1 IF a < c THEN a = a + c ELSE a = a - 1 LET c = c - 1 END IF ELSE b = b + c END IF
The 2nd way, despite being longer, can be more readable. It's up to you

The END IF for a single-line if is now optional (so you current code is still compatible):
Code:
10 REM lines 20 and 30 are equivalent 20 IF a < b THEN a = a + 1 30 IF a < b THEN a = a + 1: END IF
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)