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/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.
Updates!

https://lucidapogee.com/forum/viewtopic.php?t=93
https://lucidapogee.com/forum/viewtopic.php?t=99

There now a DOS Edition (8088 compatible), DPMI Edition (386 compatible), Win32 Edition, and Linux Edition. Still alpha version for now.

The Linux Edition has been tested on various distros.
The DOS Edition has been tested on the Book 8088.

The DOS Edition is compiled with Borland Turbo C 1.
The DPMI Edition is compiled with DJGPP.
The Win32 and Linux Editions are compiled with Open Watcom.

Each edition has almost identical source code and the examples are totally identical. This makes Express BASIC a fully cross platform programming language.

The Linux Edition provides an elf file. I'd like to know how it works on other distros. Let me know.
Hexidecimal values may now be denoted in expressions using the &H prefix.

The INP() function and OUT command has been added to the DOS Edition. It makes sense to allow DOS programmers the ability to access ports. This only works on the DOS .Edition and not DPMI, Win32, or Linux. While this allows for incompatible software to exist, the trade-off is worth it. Express BASIC for DOS is a whole new animal now. Especially with the addition of hex notation.

I tried adding Peek/Poke/Def Seg and had some luck, but still can't get it right. When I get that down I will try Varseg and Varptr. Maybe even Call Absolute.. That one looks difficult. For now, we have INP() and OUT for tinkering.

For example, INP(96) is now valid in Express BASIC. You may read keyboard input in real time.

I have updated the documentation. As always, please check it before using to avoid confusion. Please let me know if anyone has questions or wants to suggest something that is missing or incorrect.

More example programs have been added. There's a total of 18 playable games now that are cross platform between Linux, Windows, and DOS.

Here's a few of the new examples:

Code:
1 REM Percentages Quiz
2 REM by Beronica Smothers
5 PRECISION 2
10 CLS: PRINT "*** Percentages Quiz ***": PRINT
20 INPUT "How many questions"; Q
25 LET C = 0
30 FOR I = 0 TO Q - 1
40 CLS
50 LET T = INT(RND * 9) + 1
60 GOSUB T * 1000
70 PRINT: PRINT: INPUT "Enter 0 to continue or 1 to exit. ", Z
80 IF Z = 1 THEN 100
90 NEXT I
100 LET P = C / Q * 100
110 CLS: PRINT: PRINT "You got "; P; "%% of the questions correct!": PRINT
120 IF P >= 90 THEN PRINT "You got an A! Amazing!"
130 IF P >= 80 AND P < 90 THEN PRINT "You got a B! Not bad!"
140 IF P >= 70 AND P < 80 THEN PRINT "You got a C! Could have done better."
150 IF P >= 60 AND P < 70 THEN PRINT "You got a D! Needs improvement!"
160 IF P < 60 THEN PRINT "You got an F! What a catastrophe!"
170 PRINT: PRINT: INPUT "Try again? Yes(1) No(2) ", Z
180 IF Z = 1 THEN 10
190 PRINT: PRINT "Hmm...alright. You better come back!"
200 END
999 REM *** Discount
1000 LET OP = (RND * 100) + ABS(RND - 1)
1010 LET PD = INT(RND * 99) + 1
1020 LET D = OP * (PD * .01)
1030 PRINT "A video game originally costs $"; OP
1040 PRINT "It now has a "; PD;"%% discount."
1050 PRINT: INPUT "What is the discount? $", A: PRINT
1060 IF A = D THEN PRINT "Correct!": LET C = C + 1: RETURN
1070 PRINT "Incorrect! The discount is $"; D: RETURN
1999 REM *** Final price after discount
2000 LET OP = (RND * 100) + ABS(RND - 1)
2010 LET PD = INT(RND * 99) + 1
2020 LET FP = OP - (OP * (PD * .01))
2030 PRINT "A video game originally costs $"; OP
2040 PRINT "It now has a "; PD;"%% discount."
2050 PRINT: INPUT "What is the final price? $", A: PRINT
2060 IF A = FP THEN PRINT "Correct!": LET C = C + 1: RETURN
2070 PRINT "Incorrect! The final price is $"; FP: RETURN
2999 REM *** Percent discount
3000 LET FP = (RND * 100) + ABS(RND - 1)
3010 LET OP = (RND * 100) + ABS(RND - 1): IF OP <= FP THEN 3010
3020 LET PD = (1 - (FP / OP)) * 100
3030 PRINT "A video game now costs $"; FP
3040 PRINT "The original price was $"; OP
3050 PRINT: INPUT "What is the percent discount"; A: PRINT
3060 IF A = PD THEN PRINT "Correct!": LET C = C + 1: RETURN
3070 PRINT "Incorrect! The percent discount is "; PD; "%%": RETURN
3999 REM *** Original price before discount
4000 LET FP = (RND * 100) + ABS(RND - 1)
4010 LET PD = INT(RND * 99) + 1
4020 LET OP = FP / ((100 - PD) * .01)
4030 PRINT "A video game is on sale for "; PD; "%% off."
4040 PRINT "The final price is $"; FP
4050 PRINT: INPUT "What was the original price? $", A: PRINT
4060 IF A = OP THEN PRINT "Correct!": LET C = C + 1: RETURN
4070 PRINT "Incorrect! The original price is $"; OP: RETURN
4999 REM *** Final price after markup
5000 LET OP = (RND * 100) + ABS(RND - 1)
5010 LET PD = INT(RND * 99) + 1
5020 LET FP = OP + (OP * (PD * .01))
5030 PRINT "A game console costs $"; OP; " to make."
5040 PRINT "The store marks it up "; PD; "%% to make profit."
5050 PRINT: INPUT "What is the final price of the game console? $", A: PRINT
5060 IF A = FP THEN PRINT "Correct!": LET C = C + 1: RETURN
5070 PRINT "Incorrect! The final price is $"; FP: RETURN
5999 REM *** Taxes
6000 LET BT = (RND * 100) + ABS(RND - 1)
6010 LET ST = 8
6020 LET TA = BT * (ST * .01)
6030 PRINT "Your total before taxes comes out to $"; BT
6040 PRINT "Your state's sales tax is "; ST; "%%"
6050 PRINT: INPUT "How much will you be paying in taxes? $", A: PRINT
6060 IF A = TA THEN PRINT "Correct!": LET C = C + 1: RETURN
6070 PRINT "Incorrect! The tax amount is $"; TA: RETURN
6999 REM *** Total after taxes
7000 LET BT = (RND * 100) + ABS(RND - 1)
7010 LET ST = 8
7020 LET AT = BT + (BT * (ST * .01))
7030 PRINT "Your total before taxes comes out to $"; BT
7040 PRINT "Your state's sales tax is "; ST; "%%"
7050 PRINT: INPUT "What is your total after taxes? $", A: PRINT
7060 IF A = AT THEN PRINT "Correct!": LET C = C + 1: RETURN
7070 PRINT "Incorrect! Your total after taxes is $"; AT: RETURN
7999 REM *** Total after taxes
8000 LET AT = (RND * 100) + ABS(RND - 1)
8010 LET ST = 8
8020 LET BT = AT / ((100 + ST) * .01)
8030 PRINT "Your total after taxes comes out to $"; AT
8040 PRINT "Your state's sales tax is "; ST; "%%"
8050 PRINT: INPUT "What was your total before taxes? $", A: PRINT
8060 IF A = BT THEN PRINT "Correct!": LET C = C + 1: RETURN
8070 PRINT "Incorrect! Your total before taxes is $"; BT: RETURN
8999 REM *** Percent from ratio
9000 LET R1 = INT(RND * 99) + 1
9010 LET R2 = INT(RND * 100) + 1: IF R2 <= R1 THEN 9010
9020 LET P = R1 / R2 * 100
9030 PRINT "You buy a new video game and take it for a spin!"
9040 PRINT "You shot down "; R1; " out of "; R2; " enemy space ships!"
9050 PRINT: INPUT "What is your percent accuracy"; A: PRINT
9060 IF A = P THEN PRINT "Correct!": LET C = C + 1: RETURN
9070 PRINT "Incorrect! Your percent accuracy is "; P; "%%": RETURN



Code:
10 PRINT TAB(33); "SPLAT"
20 PRINT TAB(15); "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
40 PRINT: PRINT: PRINT
95 PRINT "WELCOME TO 'SPLAT' -- THE GAME THAT SIMULATES A PARACHUTE"
96 PRINT "JUMP. TRY TO OPEN YOUR CHUTE AT THE LAST POSSIBLE"
97 PRINT "MOMEMT WITHOUT GOING SPLAT."
118 PRINT: PRINT: LET D1 = 0: LET V = 0: LET A = 0: LET N = 0: LET M = 0: LET D1 = INT(9001 * RND + 1000)
119 PRINT " SELECT YOUR OWN TERMINAL VELOCITY (YES(1) NO(2))";: INPUT Z
120 IF Z = 2 THEN GOTO 128
121 IF Z <> 1 THEN PRINT "YES(1) OR NO(2)";: INPUT Z: GOTO 120
123 PRINT "WHAT TERMINAL VELOCITY (MI/HR)";:INPUT V1
125 LET V1 = V1 * (52800 / 3600): LET V = V1 + ((V1 * RND) / 20) - ((V1 * RND) / 20): GOTO 135
128 LET V1 = INT(1000 * RND)
130 PRINT "OK. TERMINAL VELOCITY = "; V1; " MI/HR"
131 LET V1 = V1 * (52800 / 3600): LET V = V1 + ((V1 * RND) / 20) - ((V1 * RND) / 20)
135 PRINT "WANT TO SELECT ACCERLERATION DUE TO GRAVITY (YES(1) OR NO(2))";
136 INPUT Z
140 IF Z = 2 THEN 150
141 IF Z <> 1 THEN PRINT "YES(1) OR NO(2)";: INPUT Z: GOTO 140
143 PRINT "WHAT ACCELERATION (FT/SEC/SEC)";: INPUT A2
145 LET A = A2 + ((A2 * RND) / 20) - ((A2 * RND) / 20): GOTO 205
150 LET Z = INT(1 + (10 * RND))
151 IF Z = 1 THEN PRINT "FINE. YOU'RE ON MERCURY. ACCELERATION=12.2FT/SEC/SEC":GOTO 161
152 IF Z = 2 THEN PRINT "ALRIGHT. YOU'RE ON VENUS. ACCELERATION=28.3FT/SEC/SEC":GOTO 162
153 IF Z = 3 THEN PRINT "THEN YOU'RE ON EARTH. ACCELERATION=32.16FT/SEC/SEC":GOTO 163
154 IF Z = 4 THEN PRINT "FINE. YOU'RE ON THE MOON. ACCELERATION=5.15FT/SEC/SEC":GOTO 164
155 IF Z = 5 THEN PRINT "ALRIGHT. YOU'RE ON MARS. ACCELERATION=12.5FT/SEC/SEC":GOTO 165
156 IF Z = 6 THEN PRINT "THEN YOU'RE ON JUPITER. ACCELERATION=85.2FT/SEC/SEC":GOTO 166
157 IF Z = 7 THEN PRINT "FINE. YOU'RE ON SATURN. ACCELERATION=37.6FT/SEC/SEC":GOTO 167
158 IF Z = 8 THEN PRINT "ALRIGHT. YOU'RE ON URANUS. ACCELERATION=33.8FT/SEC/SEC":GOTO 168
159 IF Z = 9 THEN PRINT "THEN YOU'RE ON NEPTUNE. ACCELERATION=39.6FT/SEC/SEC":GOTO 169
160 IF Z = 10 THEN PRINT "FINE. YOU'RE ON THE SUN. ACCELERATION=896FT/SEC/SEC":GOTO 170
161 LET A2 = 12.2: GOTO 145
162 LET A2 = 28.3: GOTO 145
163 LET A2 = 32.16: GOTO 145
164 LET A2 = 5.15: GOTO 145
165 LET A2 = 12.5: GOTO 145
166 LET A2 = 85.2: GOTO 145
167 LET A2 = 37.6: GOTO 145
168 LET A2 = 33.8: GOTO 145
169 LET A2 = 39.6: GOTO 145
170 LET A2 = 896: GOTO 145
205 PRINT
206 PRINT "   ALTITUDE   = "; D1; " FT"
207 PRINT "   TERM.VELOCITY   = "; V1; " FT/SEC =  +-5 %"
208 PRINT "   ACCELERATION   = "; A2; " FT/SEC/SEC = -5 %"
210 PRINT "SET THE TIMER FOR YOUR FREEFALL."
211 PRINT "HOW MANY SECONDS";: INPUT T
215 PRINT "HERE WE GO."
217 PRINT
218 PRINT "TIME (SEC)", "DIST TO FALL (FT)"
219 PRINT "==========", "================="
300 FOR I = 0 TO T STEP (T/8)
310 IF I > V / A THEN GOTO 400
320 LET D = D1 - ((A / 2) * I ^ 2)
330 IF D <= 0 THEN GOTO 900
240 PRINT I, TAB(8), D
350 NEXT I
360 GOTO 500
400 PRINT "TERMINAL VELOCITY REACHED AT T PLUS "; V / A; " SECONDS"
405 FOR I = I TO T STEP (T / 8)
410 LET D = D1 - ((V ^ 2 / (2 * A)) + (V * (I - (V / A))))
420 IF D <= 0  THEN GOTO 1010
430 PRINT I, TAB(8), D
440 NEXT I
500 PRINT "CHUTE OPEN"
510 LET K = 0: LET K1 = 0
550 FOR J = 0 TO 42
555 IF @(J) = 0 THEN GOTO 620
560 LET K = K + 1
570 IF D >= @(J) THEN GOTO 600
580 LET K1 = K1 + 1
600 NEXT J
610 GOTO 540
620 LET @(J) = D
630 IF J > 2 THEN 650
635 PRINT "AMAZING!!! NOT BAD FOR YOUR ";
636 IF J = 0 THEN PRINT "1ST ";
637 IF J = 1 THEN PRINT "2ND ";
638 IF J = 2 THEN PRINT "3RD ";
639 PRINT "SUCCESSFUL JUMP!!!": GOTO 2000
650 IF K - K1 <= .1 * K THEN GOTO 700
660 IF K - K1 <= .25 * K THEN GOTO 710
670 IF K - K1 <= .5 * K HEN GOTO 720
680 IF K - K1 <= .75 * K THEN GOTO 730
690 IF K - K1 <= .9 * K THEN GOTO 740
695 GOTO 750
700 PRINT "WOW! THAT'S SOME JUMPING. OF THE "; K; " SUCCESFUL JUMPS"
701 PRINT "BEFORE YOURS, ONLY "; K - K1; " OPENED THEIR CHUTE LOWER THAN"
702 PRINT "YOU DID."
703 GOTO 2000
710 PRINT "PRETTY GOOD! "; K; " SUCCESSFUL JUMPS PRECEDED YOURS AND ONLY"
711 PRINT K - K1; " OF THEM GOT LOWER THAN YOU DID BEFORE THEIR CHUTES"
712 PRINT "OPENED.": GOTO 2000
720 PRINT "NOT BAD. THERE HAVE BEEN "; K; " SUCCESSFUL JUMPS BEFORE YOURS."
721 PRINT "YOU WERE BEATEN OUT BY "; K - K1; " OF THEM.": GOTO 2000
730 PRINT "CONSERVATIVE AREN'T YOU? YOU RANKED ONLY "; K - K1; " IN THE"
731 PRINT K; " SUCCESSFUL JUMPS BEFORE YOURS.": GOTO 2000
740 PRINT "HUMPH! DON'T YOU HAVE ANY SPORTING BLOOD? THERE WERE"
741 PRINT K; " SUCCESSFUL JUMPS BEFORE YOURS AND YOU CAME IN "; K1; " JUMPS"
742 PRINT "BETTER THAN THE WORST. SHAPE UP!!!": GOTO 2000
750 PRINT "HEY! YOU PULLED THE RIP CORD MUCH TOO SOON. "; K; " SUCCESSFUL"
751 PRINT "JUMPS BEFORE YOURS AND YOU CAME IN NUMBER "; K- K1; "! GET WITH IT!"
752 GOTO 2000
800 PRINT "REQUIESCAT IN PEACE.": GOTO 1950
801 PRINT "MAY THE ANGEL OF HEAVEN LEAD YOU INTO PARADISE": GOTO 1950
802 PRINT "REST IN PEACE": GOTO 1950
803 PRINT "SON-OF-A-GUN": GOTO 1950
804 PRINT "#$%&&%!$": GOTO 1950
805 PRINT "A KICK IN THE PANTS IS A BOOST IF YOU'RE HEADED RIGHT": GOTO 1950
806 PRINT "HMMM. SHOULD HAVE PICKED A SHORTER TIME.": GOTO 1950
807 PRINT "MUTTER. MUTTER. MUTTER": GOTO 1950
808 PRINT "PUSHING UP DAISIES.": GOTO 1950
809 PRINT "EASY COME, EASY GO.": GOTO 1950
900 PRINT SQR(2 * D1 / A), "SPLAT"
1000 LET Z = INT(1 + (10 * RND)): IF Z = 1 THEN 800
1001 IF Z = 2 THEN 801
1002 IF Z = 3 THEN 802
1003 IF Z = 4 THEN 803
1004 IF Z = 5 THEN 804
1005 IF Z = 6 THEN 805
1006 IF Z = 7 THEN 806
1007 IF Z = 8 THEN 807
1008 IF Z = 9 THEN 808
1009 IF Z = 10 THEN 809
1010 PRINT (V / A) + ((D1 - (V ^ 2 / (2 * A))) / V), "SPLAT"
1020 GOTO 1000
1950 PRINT "I'LL GIVE YOU ANOTHER CHANCE." GOTO 2000
2000 PRINT "DO YOU WANT TO PLAY AGAIN YES(1) OR NO(2)";: INPUT Z
2001 IF Z = 1 THEN GOTO 118
2002 IF Z = 2 THEN GOTO 2005
2003 PRINT "YES(1) OR NO(2)": GOTO 2000
2005 PRINT "PLEASE";: INPUT Z: IF Z = 1 THEN 118
2006 IF Z <> 2 THEN PRINT "YES(1) OR NO(2)";: GOTO 2005
2007 PRINT "SSSSSSSSSS.": GOTO 2046
2046 END



Code:
10 PRINT TAB(32); "REVERSE"
20 PRINT TAB(15); "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 PRINT: PRINT: PRINT
100 PRINT "REVERSE -- A GAME OF SKILL": PRINT
140 REM *** N = NUMBER OF NUMBERS
150 LET N = 9
160 PRINT "DO YOU WANT THE RULES YES(1) NO(2)";
170 INPUT A
180 IF A = 2 THEN 210
190 GOSUB 710
200 REM *** MAKE A RANDOM LIST A(1) TO A(N)
210 LET @(1) = INT((N - 1) * RND + 2)
220 FOR K = 2 TO N
230 LET @(K) = INT(N * RND + 1)
240 FOR J = 1 TO K - 1
250 IF @(K) = @(J) THEN 230
260 NEXT J
261 NEXT K
280 REM *** PRINT ORIGINAL LIST AND START GAME
290 PRINT: PRINT "HERE WE GO ... THE LIST IS:"
310 LET T = 0
320 GOSUB 610
330 PRINT "HOW MANY SHALL I REVERSE";
340 INPUT R
350 IF R = 0 THEN 520
360 IF R <= N THEN 390
370 PRINT "OOPS!     TOO MANY!    I CAN REVERSE AT MOST"; N: GOTO 330
390 LET T = T + 1
400 REM *** REVERSE R NUMBERS AND PRINT NEW LIST
410 FOR K = 1 TO INT(R / 2)
420 LET Z = @(K)
430 LET @(K) = @(R - K + 1)
440 LET @(R - K + 1) = Z
450 NEXT K
460 GOSUB 610
470 REM *** CHECK FOR A WIN
480 FOR K = 1 TO N
490 IF @(K) <> K THEN 330
500 NEXT K
510 PRINT "YOU WON IT IN "; T; " MOVES!!!": PRINT
520 PRINT
530 PRINT "TRY AGAIN (YES(1) NO(2))";
540 INPUT A
550 IF A = 1 THEN 210
560 PRINT: PRINT "O.K. HOPE YOU HAD FUN!!": GOTO 999
600 REM *** SUBROUTINE TO PRINT LIST
610 PRINT
611 FOR K = 1 TO N
612 PRINT @(K);
613 NEXT K
650 PRINT: PRINT: RETURN
700 REM *** SUBROUTINE TO PRINT THE RULES
710 PRINT: PRINT "THIS IS THE GAME OF 'REVERSE'. TO WIN, ALL YOU HAVE"
720 PRINT "TO DO IS ARRANGE A LIST OF NUMBERS (1 THROUGH ";N; ")"
730 PRINT "IN NUMERICAL ORDER FROM LEFT TO RIGHT. TO MOVE, YOU"
740 PRINT "TELL ME HOW MANY NUMBERS (COUNTING FROM THE LEFT) TO"
750 PRINT "REVERSE. FOR EXAMPLE, IF THE CURRENT LIST IS:"
760 PRINT: PRINT "2 3 4 5 1 6 7 8 9"
770 PRINT: PRINT "NOW IF YOU REVERSE 5, YOU WIN!"
800 PRINT: PRINT "1 2 3 4 5 6 7 8 9": PRINT
810 PRINT "NO DOUBT YOU WILL LIKE THIS GAME, BUT"
820 PRINT "IF YOU WANT TO QUIT, REVERSE 0 (ZERO).": PRINT: RETURN
999 END
Here's a simple demo of sending output to the parallel port in DOS.

Code:
10 FOR i = 1 TO 255
20 PRINT CHR$(i),: OUT &H378, i
30 LET t = TIMER
40 IF TIMER < t + 1 THEN 40
50 NEXT i

The output is viewable with a rs232 quick tester
This week brings a big update.

Handling of negation has been improved. For example, -(10 +1) returns -11 as it should. As opposed to -9. I had never accounted for negating outside of parenthesis. Only in front of a variable or literal value. The solution for now is to swap the - with a _1* and later swap the _ back to a - while processing the infix.

A bug with GOSUB was fixed. We're working on making the subs and for loops work with the colons. For now, just the subs.

There's three new examples.

This particular example wasn't working correctly until I fixed the negation handling. I think it shows the progress that we're making.


Code:

1 REM PLOT A NORMAL DISTRIBUTION CURVE
2 REM PORTED TO EXPRESS BASIC
3 REM FROM THE DTSS EMULATOR MANUAL "A BASIC OUTLINE"
10 FOR X = -2 TO 2 STEP .1
20 PRINT TAB(INT(100 * (EXP(-(X ^ 2 / 2)) / SQR(2 * PI)))); "*"
30 NEXT X
  
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