-
Notifications
You must be signed in to change notification settings - Fork 0
BASCOMP programming examples
Since you are here, you will probably know the basics about BASIC. BASCOMP implements a subset of statements and functions found in GW-BASIC, MS QuickBASIC and other dialects.
In a nutshell: Many easy traditional and QB BASIC programs should "just work", while larger and/or more specific programs will need smaller or larger modifications. If you are looking for some inspiration, this page is designed to give you bits and pieces of code showing what BASCOMP can do.
This little programm will execute the ROT13 algorithm on a given text string.
10 REM ===============================================================
20 REM ROT13.BAS
30 REM ROT13 ENCODER/DECODER FOR BASCOMP
40 REM ===============================================================
50 CLS
60 PRINT "ROT13 TEST"
70 PRINT "ENTER TEXT:"
80 INPUT T$
90 R$ = ""
100 I = 1
110 IF I > LEN(T$) THEN GOTO 300
120 C$ = MID$(T$, I, 1)
130 A = ASC(C$)
140 REM ----- A..Z -----
150 IF A >= 65 AND A <= 90 THEN GOTO 200
160 REM ----- a..z -----
170 IF A >= 97 AND A <= 122 THEN GOTO 240
180 R$ = R$ + C$
190 GOTO 280
200 A = A + 13
210 IF A > 90 THEN A = A - 26
220 R$ = R$ + CHR$(A)
230 GOTO 280
240 A = A + 13
250 IF A > 122 THEN A = A - 26
260 R$ = R$ + CHR$(A)
270 GOTO 280
280 I = I + 1
290 GOTO 110
300 PRINT "ROT13:"
310 PRINT R$
320 PRINT "APPLYING ROT13 AGAIN RETURNS THE ORIGINAL TEXT."
330 ENDThis program will need BASCOMP 2.0 and a suitable 256 colors display (VGA), showing of the graphical abilities (and some math functions) of BASCOMP. The execution speed will depend on your (physical/emulated) cpu.
10 REM ============================================
20 REM BASCOMP GRAPHICS DEMO: FULL 320x200 MANDELBROT
30 REM Requires SCREEN and PSET support
40 REM SCREEN 13 = 320x200, 256 colors
50 REM ESC aborts after each completed row
60 REM Fixed-point integer arithmetic, scale S=48
70 REM ============================================
80 SCREEN 13
90 S = 48: LIM = 192: MAXIT = 32
100 FOR PY = 0 TO 199
110 CY = (PY - 100) * 12 / 25
120 FOR PX = 0 TO 319
130 CX = PX * 9 / 20 - 96
140 ZX = 0: ZY = 0: I = 0
150 IF ABS(ZX) > 95 THEN GOTO 270
160 IF ABS(ZY) > 95 THEN GOTO 270
170 ZX2 = ZX * ZX / S
180 ZY2 = ZY * ZY / S
190 IF ZX2 + ZY2 > LIM THEN GOTO 270
200 IF I >= MAXIT THEN GOTO 270
210 NZX = ZX2 - ZY2 + CX
220 NZY = 2 * ZX * ZY / S + CY
230 ZX = NZX
240 ZY = NZY
250 I = I + 1
260 GOTO 150
270 CLR = I + 1
280 IF I < MAXIT THEN GOTO 300
290 CLR = 0
300 PSET PX, PY, CLR
310 NEXT PX
320 K$ = INKEY$
330 IF K$ = CHR$(27) THEN GOTO 380
340 NEXT PY
350 REM Wait for any key before returning to text mode
360 K$ = INKEY$
370 IF K$ = "" THEN GOTO 360
380 SCREEN 0
390 COLOR 7, 0
400 CLS
410 PRINT "DONE."
420 END