Information Technology - Computer Programming - Source Code - Homebrew - Open Source - Software - Hardware - 8 bit - 16 bit - 32 bit - 64 bit - x86 - x64 - DOS - Windows - Linux - Arduino - Embedded - Development - Retro - Vintage - Math - Science - History - Hobby - Beginners - Professionals - Experiment - Research - Study - Fun - Games

Massive Express BASIC update!

Updates about our products and services.
Post Reply
admin
Site Admin
Posts: 115
Joined: Wed Feb 22, 2023 6:51 am

Massive Express BASIC update!

Post by admin »

We have been working hard for the past few weeks on this update and have made a lot of progress.

Here's a few things that have been added or fixed:

It is no longer required to have a blank line at the end of .bas source files.
Also, it seems that Linux actually doesn't seem to have a problem running EB with .bas files through the command line.

A few nasty bugs that caused the interpreter to crash have been fixed.
One was the INPUT buffer getting corrupted when non numerical input was accepted. Now fixed.
The other was if you tried deleting a line with a line number that hasn't been defined. Now fixed.

The ON command has been added. It supports ON GOTO and ON GOSUB.
Use of the LET command for assignment is now optional. Code the way you want to.

Some error checking for missing keywords in statements has been added.
There's also now some error checking for invalid expressions.

The MILLISECS function was removed due to inconsistency. There's still a TIMER function.

Several new examples have been added including...

Code: Select all

1 REM https://rosettacode.org/wiki/2048
2 REM Clone by Beronica Smothers
10 grid = 4: GOSUB 5000
20 IF invalid = 0 THEN GOSUB 5000
30 GOSUB 6000: IF count = grid ^ 2 THEN GOSUB 7000
40 INPUT "Your move"; move: IF move = 5 THEN END
50 IF move < 1 OR move > 5 THEN 30
60 s = 0: FOR i = 0 TO grid - 1: GOSUB move * 1000: NEXT i
70 IF w = 1 THEN GOSUB 6000: PRINT TAB(10); "You win!!": PRINT: GOSUB 8500: GOTO 40
80 IF s = 0 AND count < grid ^ 2 THEN PRINT "Invalid move.": GOSUB 8500: invalid = 1
85 IF s THEN invalid = 0
90 GOTO 20
100 END
1000 startpos = i: endpos = grid * (grid - 1) + i
1010 GOSUB 1500
1020 FOR j = startpos TO endpos - grid STEP grid
1030 IF NOT(@(j) AND @(j) = @(j + grid)) THEN 1050
1040 @(j) = @(j) * 2: @(j + grid) = 0: IF @(j) = 1048 THEN w = 1
1045 score = score + @(j): s = 1: count = count - 1
1050 NEXT j
1060 GOSUB 1500: RETURN
1500 FOR k = startpos TO endpos - grid STEP grid
1510 IF @(k) THEN 1550
1520 FOR l = k + grid TO endpos STEP grid
1530 IF @(l) THEN @(k) = @(l): @(l) = 0: s = 1: BREAK l
1540 NEXT l
1550 NEXT k: RETURN
2000 startpos = grid * i: endpos = startpos + grid - 1
2010 GOSUB 2500
2020 FOR j = endpos TO startpos + 1 STEP - 1
2030 IF NOT(@(j) AND @(j) = @(j - 1)) THEN 2050
2040 @(j) = @(j) * 2: @(j - 1) = 0: IF @(j) = 2048 THEN w = 1
2045 score = score + @(j): s = 1: count = count - 1
2050 NEXT J
2060 GOSUB 2500: RETURN
2500 FOR k = endpos TO startpos + 1 STEP - 1
2510 IF @(k) THEN 2550
2520 FOR l = k - 1 TO startpos STEP - 1
2530 IF @(l) THEN @(k) = @(l): @(l) = 0: s = 1: BREAK l
2540 NEXT l
2550 NEXT k: RETURN
3000 startpos = i : endpos = grid * (grid - 1) + i
3010 GOSUB 3500
3020 FOR j = endpos TO startpos + grid STEP - grid
3030 IF NOT(@(j) AND @(j) = @(j - grid)) THEN 3050
3040 @(j) = @(j) * 2: @(j - grid) = 0: IF @(j) = 3048 THEN w = 1
3045 score = score + @(j): s = 1: count = count - 1
3050 NEXT j
3060 GOSUB 3500: RETURN
3500 FOR k = endpos TO startpos + grid STEP - grid
3510 IF @(k) THEN 3550
3520 FOR l = k - grid TO startpos STEP - grid
3530 IF @(l) THEN @(k) = @(l): @(l) = 0: s = 1: BREAK l
3540 NEXT l
3550 NEXT k: RETURN
4000 startpos = grid * i: endpos = startpos + grid - 1
4010 GOSUB 4500
4020 FOR j = startpos TO endpos - 1
4030 IF NOT(@(j) AND @(j) = @(j + 1)) THEN 4050
4040 @(j) = @(j) * 2: @(j + 1) = 0: IF @(j) = 2048 THEN w = 1
4045 score = score + @(j): s = 1: count = count - 1
4050 NEXT j
4060 GOSUB 4500: RETURN
4500 FOR k = startpos TO endpos - 1
4510 IF @(k) THEN 4550
4520 FOR l = k + 1 TO endpos
4530 If @(l) THEN @(k) = @(l): @(l) = 0: s = 1: BREAK l
4540 NEXT l
4550 NEXT k: RETURN
5000 count = count + 1
5010 new = RND * (grid ^ 2): IF @(new) THEN 5010
5020 chance = RND * 10: IF NOT(chance) THEN @(new) = 4: RETURN
5030 @(new) = 2: RETURN
6000 CLS:  PRINT "*---2048---*", "Score: "; score: PRINT
6010 FOR x = 0 TO grid ^ 2 - 1
6020 IF @(x) THEN PRINT @(x),
6030 IF NOT(@(x)) THEN PRINT "_",
6040 IF (x + 1) mod grid = 0 THEN PRINT: PRINT
6050 NEXT x
6060 PRINT TAB(12); "[1:^]": PRINT TAB(6); "[4:<]"; TAB(8); "[2:>]": PRINT TAB(12); "[3:v]"
6070 PRINT: PRINT TAB(10); "[5: Exit]": PRINT: RETURN
7000 f = 0
7010 FOR i = 0 TO grid - 1
7020 GOSUB 8000: IF f THEN BREAK i
7030 NEXT i
7040 IF NOT(f) THEN PRINT: PRINT "Out of moves!": END
7050 RETURN
8000 startpos = i: endpos = grid * (grid - 1) + i
8010 FOR j = startpos TO endpos - grid STEP grid
8020 IF @(j) AND @(j) = @(j + grid) THEN f = 1: BREAK j
8030 NEXT j: IF f THEN RETURN
8040 startpos = grid * i: endpos = startpos + grid - 1
8050 FOR j = endpos TO startpos + 1 STEP - 1
8060 IF @(j) AND @(j) = @(j - 1) THEN f = 1: BREAK j
8070 NEXT j: IF f THEN RETURN
8080 startpos = i : endpos = grid * (grid - 1) + i
8090 FOR j = endpos TO startpos + grid STEP - grid
8100 IF @(j) AND @(j) = @(j - grid) THEN f = 1: BREAK j
8110 NEXT j: IF f THEN RETURN
8120 startpos = grid * i: endpos = startpos + grid - 1
8130 FOR j = startpos TO endpos - 1
8140 IF @(j) AND @(j) = @(j + 1) THEN f = 1: BREAK j
8150 NEXT j: RETURN
8500 t = TIMER
8510 IF TIMER > t + 3 THEN RETURN
8520 GOTO 8510
Post Reply