Express BASIC is a minimal BASIC dialect that is suitable for performing complex calculations. The language is inspired by Dartmouth, Palo Alto, Altair, GW BASIC, and the many dialects of Tiny BASIC. The interpreter is written in C and is open source.

The goal of this language is to develop and maintain a syntax that is more standard than Craft Basic or Commando Basic. Programs may be copy/pasted into GW BASIC with little to no modification. The syntax of Express BASIC and Net Basic are intended to be similar. This allows you to write code that works locally and on the net.

Available for all versions of Windows 95 and up. It's a Windows console program, so it will work on 10 and 11.

Get it here: https://lucidapogee.com/index.php?page=expressbasic


Here's a few examples...


Code:
10 REM ROCKET.BAS by Brian Tung
20 REM Modified to work with Express Basic
30 LET a = 1.032
40 LET d = 1
50 PRINT "Earth gravity in light-years per year squared: "; a
55 PRINT "Distance in light-years (0-100 million): "; d
60 IF d >= 0 AND d <= 100000000 THEN 80
70 PRINT "Distance must be between 0 and 100 million l-y"
75 END
80 LET d1 = d / 2
90 LET t = SQR(d1 * d1 + (2 * d1 / a))
100 LET x = a * t
110 LET m = 1
120 IF x >= 0 THEN 130
125 LET m = -1
130 LET s = LOG(ABS(x) + 1)
140 LET s1 = s + 1
150 LET x1 = (EXP(s) - EXP(s * -1)) / 2 - ABS(x)
160 LET s1 = x1 / (EXP(s) + EXP(s * -1)) / 2
170 LET s = s - s1
180 IF ABS(s1) > .0000001 THEN 150
190 LET t1 = 1 / a * s * m
200 LET v = a * t / SQR(1 + (a * t) * (a * t))
210 PRINT "Time on Earth: "; 2 * t; " years"
220 PRINT "Time on board: "; 2 * t1; " years"
230 SHELL "pause"



Code:
1 REM MODIFIED TO WORK WITH EXPRESS BASIC
10 PRINT "HURKLE"
20 PRINT "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
30 PRINT
110 LET N=5
120 LET G=10
210 PRINT
220 PRINT "A HURKLE IS HIDING ON A ";G;" BY ";G;" GRID. HOMEBASE"
230 PRINT "ON THE GRID IS POINT 0,0 IN THE SOUTHWEST CORNER,"
235 PRINT "AND ANY POINT ON THE GRID IS DESIGNATED BY A"
240 PRINT "PAIR OF WHOLE NUMBERS. THE FIRST NUMBER IS"
245 PRINT "THE HORIZONTAL POSITION AND THE SECOND NUMBER"
246 PRINT "IS THE VERTICAL POSITION. YOU MUST TRY TO"
250 PRINT "GUESS THE HURKLE'S GRIDPOINT. YOU GET ";N;" TRIES."
260 PRINT "AFTER EACH TRY, I WILL TELL YOU THE APPROXIMATE"
270 PRINT "DIRECTION TO GO TO LOOK FOR THE HURKLE."
280 PRINT
285 LET A=INT(G*RND)
286 LET B=INT(G*RND)
290 LET K = 0
310 LET K = K + 1
320 PRINT "GUESS #";K
330 INPUT "X: ", X
335 INPUT "Y: ", Y
340 IF ABS(X-A)+ABS(Y-B)=0 THEN 500
350 REM PRINT INFO
360 GOSUB 610
370 PRINT
380 IF K <= N THEN 310
410 PRINT
420 PRINT "SORRY, THAT'S ";N;" GUESSES."
430 PRINT "THE HURKLE IS AT ";A;",";B
440 PRINT
450 PRINT "LET'S PLAY AGAIN, HURKLE IS HIDING."
460 PRINT
470 GOTO 285
500 REM
510 PRINT
520 PRINT "YOU FOUND HIM IN ";K;" GUESSES!"
540 GOTO 440
610 PRINT "GO ";
620 IF Y=B THEN 670
630 IF Y<B THEN 660
640 PRINT "SOUTH";
650 GOTO 670
660 PRINT "NORTH";
670 IF X=A THEN 720
680 IF X<A THEN 710
690 PRINT "WEST";
700 GOTO 720
710 PRINT "EAST";
720 PRINT
730 RETURN
999 END



Code:
1 REM https://rosettacode.org/wiki/Attractive_numbers
10 FOR x = 1 TO 120
20 LET n = x
30 LET c = 0
40 IF n MOD 2 <> 0 THEN 70
50 LET n = INT(n / 2)
60 LET c = c + 1
70 IF n MOD 2 = 0 THEN 40
80 FOR i = 3 TO SQR(n) STEP 2
90 IF n MOD i <> 0 THEN 120
100 LET n = INT(n / i)
110 LET c = c + 1
120 IF n MOD i = 0 THEN 90
130 NEXT i
140 IF n <= 2 THEN 160
150 LET c = c + 1
160 IF NOT(PRIME(c)) THEN 180
170 PRINT x,
180 NEXT x
190 PRINT
200 SHELL "pause"



Code:
1 REM https://rosettacode.org/wiki/Golden_ratio/Convergence
5 PRECISION 6
10 LET phi0 = 1
20 LET phi1 = 1 / phi0 + 1
30 LET d = ABS(phi1 - phi0)
40 LET phi0 = phi1
50 LET i = i + 1
60 IF d >= .00001 THEN 20
70 PRINT "result: "; phi1; " after "; i; " iterations"
80 PRINT "the error is approximately "; phi1 - (.5 * (1 + SQR(5)))
90 SHELL "pause"



Code:
1 REM https://rosettacode.org/wiki/Nth_root
5 PRECISION 6
10 LET a = INT(RND * 5999) + 2
20 PRINT "nth root of "; a; "..."
30 FOR n = 1 TO 10
40 LET p = .00001
50 LET x = a
60 LET y = a / n
70 IF ABS(x - y) <= p THEN 110
80 LET x = y
90 LET y = ((n - 1) * y + a / y ^ (n - 1)) / n
100 IF ABS(x - y) > p THEN 80
110 PRINT n; " : "; y
120 NEXT n
130 SHELL "pause"
Hey welcome to the forums, this looks really cool! I'll have to try it out for sure.

Do you plan on adding any graphics capability to it?
Thank you. Glad to be here.

I created this interpreter with a few goals in mind. Mainly to stick to a mostly standard traditional BASIC syntax. Meaning programs made with it will run in QBasic with little to no modification.

Another goal was to develop it with C. I ended up with a mess of both C and C++, but mostly C. My other languages are either written in BASIC or PHP.

Finally, the last goal was to make the interpreter as small as possible (currently 46kb). Also should be minimal and easy to port.

As a result, things like graphics become extra challenging. I have been messing around with allegro.h, graphics.h, gl, and gdi, but have been facing all sorts of design challenges.

I either can't get one to work while another is too large and others require more time for me to research and experiment. The interpreter is currently only a few weeks old.

One big problem is deciding how to continue keeping the BASIC syntax backward compatible while using libraries that are easy to port. For example, the SCREEN command with DOS screen modes. It gets complex trying to simulate that in windows. I could add a new set of commands similar to newer BASIC implementations, but that might be out of the scope of what's intended.

Another thing is this is a command line BASIC interface. Opening a window and passing control to it then back to the console. I am not that advanced in C yet unfortunately.

For now, it is out of the scope to do graphics. I plan to change that when I figure out a solution.
I have been working on trying to implement graphics and have had no luck with libraries. Ended up borrowing more BCX routines. Amazingly, you can draw to the console directly! Wow!

There's now two versions of Express Basic. Minimal and Extended Editions. The minimal contains no Windows features and should be easy enough to port to Linux while the Extended Edition depends on Windows for graphics commands.

Links on the download page are updated for the Minimal and Extended Editions.

New features in the extended edition include:


Code:

PSET (x, y)
LINE (x1, y1)-(x2, y2)
CIRCLE (x, y), radius
COLOR doscolors
RGB red, green, blue
WAV "sync:filename.wav"


PSET only accepts x and y parameters.
LINE only accepts x1, y1, x2, and y2.
CIRCLE only accepts x, y, and radius
COLOR accepts 0-15
RGB accepts 0-255 for rgb values.
Expressions may be used anywhere in these commands. This includes expressions with ()-(). For example, LINE ((150/2)-(3*2),(14*5)-(6+7))-((123-44)-(5-66),(42*7)-(66+45)) will draw the same line in QBasic and Express BASIC without modification. I went out of my way to require the extra weird syntax with the ()-().
PSET and CIRCLE are similar.
WAV requires sync: or async: in the quotes to the left of the filename. I thought this was a quick and dirty solution.

The Minimal Edition does not have the following commands: ALERT, LOCATE, PSET, LINE, CIRCLE, COLOR, RGB, WAV, SOUND

I changed the TIMER and MILLISECS function to use clock() instead of GetSystemTime(). This removes the windows.h dependency from both editions for randomization seeding, TIMER, and MILLISECS. For timer, I am just using clock()/1000. Millisecs is clock(). The big difference is that now the count is from when the program starts. For the random seeding, I am using time(NULL).

I also fixed a little issue with LOCATE. It was expecting 0, 0 as the top left. Now it accepts 1, 1 like QBasic.

Here's some of the graphics examples included with the Extended Edition:


Code:

1 REM https://rosettacode.org/wiki/Draw_a_sphere
5 CLS
10 LET j = 2
20 FOR i = 51 TO 0 STEP j * -1
30 FOR k = PI * -1 TO PI STEP .05
40 PSET (51 + i * sin(k), 52 + 51 * cos(k))
50 PSET (51 + 51 * sin(k), 52 + (i - 1) * cos(k))
60 NEXT k
70 LET j = j + 1
80 NEXT i
90 SHELL "pause"




Code:

1 REM https://rosettacode.org/wiki/Barnsley_fern
2 CLS
5 COLOR 10
10 FOR i = 1 TO 10000
20 LET r = RND
30 IF NOT(r > 0 AND r < .01) THEN 60
40 LET x = .0
50 LET y = .16 * y
60 IF NOT(r > .01 AND r < .08) THEN 90
70 LET x = .22 * x - .26 * y
80 LET y = -.23 * x + .22 * y + 1.6
90 IF NOT(r > .075 AND r < .15) THEN 120
100 LET x = .15 * x + .28 * y
110 LET y = -.29 * x + .24 * y + .44
120 LET x = .85 * x + .04 * y
130 LET y = -.04 * x + .85 * y + 1.6
140 LET x1 = (x + 3) * 20
150 LET y1 = 200 - y * 20
160 PSET (x1, y1)
170 NEXT i
180 SHELL "pause"




Code:

1 REM https://rosettacode.org/wiki/Mandelbrot_set
5 CLS
10 LET max = 15
20 LET w = 319
30 LET h = 199
40 LET px = 0
50 LET sy = (py - h / 2) / 150
60 LET sx = (px - w / 2) / 150
70 LET i = 0
80 LET x = 0
90 LET y = 0
100 LET xy = x * x + y * y
110 LET xx = x * x - y * y + sx + .1
120 LET y = 2 * x * y + sy
130 LET x = xx
140 LET i = i + 1
150 IF i < max AND xy < 1 THEN 110
160 RGB 220 + i * x, 220 + i * y, 230 + i * xy
170 PSET (px, py)
180 LET px = px + 1
190 IF px < w THEN 50
200 LET py = py + 1
210 IF py < h THEN 40
220 LOCATE 25, 1
230 SHELL "pause"




Code:

1 REM https://rosettacode.org/wiki/Munching_squares
5 CLS
10 LET s = 255
20 FOR y = 0 TO s
30 FOR x = 0 TO s
40 LET r = x XOR y
50 RGB r, r * 2, r * 3
60 PSET (x, y)
70 NEXT x
80 NEXT y
90 LOCATE 25, 1
100 SHELL "pause"




Code:

2 CLS
5 COLOR 15
10 FOR f = 0 TO 1000 STEP .1
20 LET x = x + SIN(f * f)
30 LET y = y + COS(f * f)
40 PSET (x + 200, y + 20)
50 NEXT f
60 SHELL "pause"

Until now, the current editions of Express BASIC are compiled with Dev C++. Internally, gcc.
I had no luck getting this to work with Borland, so I tried DJGPP. A port of gcc.

Now there's a DOS and 9x Edition. The only issues are the larger exe size and dependency on DPMI server. I also need to figure out how to bind the DPMI to the application. Even better, maybe remove the dependency if possible.

So far, the DOS and 9x Edition has been tested on DOS 3.0, Free DOS, Windows 95, and Windows XP.

This is all experimental, so everything is subject to change. I plan to update the Edition names later on.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement