Author Topic: Vintage BASIC Interpreter  (Read 6850 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Vintage BASIC Interpreter
« on: October 12, 2018, 09:34:23 PM »
Quote
Vintage BASIC is an interpreter for a programming language of days gone by. A time when every home computer had a simple language called BASIC, and every kid who owned a computer learned it. It is implemented in Haskell, a modern language very unlike BASIC. I constructed it, beginning in Prof. Tim Sheard's Advanced Functional Programming Class, as a way to demonstrate how Haskell's monads could be used to implement BASIC's dynamic control structures. This odd marriage has now produced a fully functional implementation of that old favorite.

Vintage BASIC is open source software, provided under the BSD license. It will run on any platform that supports the GHC compiler, including Windows, macOS, and Linux.

I might create a 3D Tic-Tac-Toe GUI VB6 OCX object and use the code (logic) from the Vintage game. This is the point I was trying to make about Script BASIC's flexibility and functionality range.


Project Site

Vintage Basic Games

Classic Basic Games Page

Code: [Select]
10 LINES=17
20 FORI=1TOLINES/2+1
30 FORJ=1TO(LINES+1)/2-I+1:PRINT" ";:NEXT
40 FORJ=1TOI*2-1:PRINT"*";:NEXT
50 PRINT
60 NEXTI
70 FORI=1TOLIVES/2:REM note misspelled variable is the same
75 REM because variables are unique to only two characters
80 FORJ=1TOI+1:PRINT" ";:NEXT
90 FORJ=1TO((LINES+1)/2-I)*2-1:PRINT"*";:NEXT
100 PRINT
110 NEXTI


$ ./vintbas ../test/diamond.bas
         *
        ***
       *****
      *******
     *********
    ***********
   *************
  ***************
 *****************
  ***************
   *************
    ***********
     *********
      *******
       *****
        ***
         *


Code: [Select]
10 INPUT"ENTER A NUMBER";N
20 ?"ABS(N)=";ABS(N)
25 ?"ATN(N)=";ATN(N)
30 ?"COS(N)=";COS(N)
40 ?"EXP(N)=";EXP(N)
50 ?"INT(N)=";INT(N)
60 ?"LOG(N)=";LOG(N)
70 ?"SGN(N)=";SGN(N)
80 ?"SQR(N)=";SQR(N)
90 ?"TAN(N)=";TAN(N)


$ ./vintbas ../test/math.bas
ENTER A NUMBER? 64
ABS(N)= 64
ATN(N)= 1.5551726
COS(N)= .39185724
EXP(N)= 6.235149E+27
INT(N)= 64
LOG(N)= 4.158883
SGN(N)= 1
SQR(N)= 8
TAN(N)= 2.3478603


Code: [Select]
10 INPUT"WHAT IS YOUR NAME";NAME$
20 INPUT"ENTER A NUMBER";N
30 FORI=1TON
40 ?"HELLO, ";NAME$;"!"
50 NEXT


$ ./vintbas ../test/name.bas
WHAT IS YOUR NAME? John
ENTER A NUMBER? 5
HELLO, John!
HELLO, John!
HELLO, John!
HELLO, John!
HELLO, John!


Code: [Select]
10 INPUT "What is your name"; U$
20 PRINT "Hello "; U$
30 INPUT "How many stars do you want"; N
40 S$ = ""
50 FOR I = 1 TO N
60 S$ = S$ + "*"
70 NEXT I
80 PRINT S$
90 INPUT "Do you want more stars"; A$
100 IF LEN(A$) = 0 THEN 90
110 A$ = LEFT$(A$, 1)
120 IF A$ = "Y" OR A$ = "y" THEN 30
130 PRINT "Goodbye ";U$
140 END


$ ./vintbas ../test/stars.bas
What is your name? John
Hello John
How many stars do you want? 5
*****
Do you want more stars? n
Goodbye John


Code: [Select]
10 INPUT"ENTER A STRING";A$
20 INPUT"ENTER A NUMBER";N
30 ?"ASC(A$)=";ASC(A$)
40 ?"CHR$(N)=";CHR$(N)
50 ?"LEFT$(A$,N)=";LEFT$(A$,N)
60 ?"MID$(A$,N)=";MID$(A$,N)
70 ?"MID$(A$,N,3)=";MID$(A$,N,3)
80 ?"RIGHT$(A$,N)=";RIGHT$(A$,N)
90 ?"LEN(A$)=";LEN(A$)
100 ?"VAL(A$)=";VAL(A$)
110 ?"STR$(N)=";STR$(N)
120 ?"SPC(N)='";SPC(N);"'"


$ ./vintbas ../test/string.bas
ENTER A STRING? BASIC
ENTER A NUMBER? 5
ASC(A$)= 66
CHR$(N)=
LEFT$(A$,N)=BASIC
MID$(A$,N)=C
MID$(A$,N,3)=C
RIGHT$(A$,N)=BASIC
LEN(A$)= 5
VAL(A$)= 0
STR$(N)= 5
SPC(N)='     '


TIC-TAC-TOE
Code: [Select]
50 PRINT CHR$(26):REM WIDTH 80
100 PRINT TAB(33);"QUBIC":PRINT
110 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
120 PRINT:PRINT:PRINT
210 PRINT "DO YOU WANT INSTRUCTIONS";
220 INPUT C$
230 IF LEFT$(C$,1)="N" THEN 315
240 IF LEFT$(C$,1)="Y" THEN 265
250 PRINT "INCORRECT ANSWER.  PLEASE TYPE 'YES' OR 'NO'";
260 GOTO 220
265 PRINT
270 PRINT "THE GAME IS TIC-TAC-TOE IN A 4 X 4 X 4 CUBE."
280 PRINT "EACH MOVE IS INDICATED BY A 3 DIGIT NUMBER, WITH EACH"
290 PRINT "DIGIT BETWEEN 1 AND 4 INCLUSIVE.  THE DIGITS INDICATE THE"
300 PRINT "LEVEL, ROW, AND COLUMN, RESPECTIVELY, OF THE OCCUPIED"
305 PRINT "PLACE.  "
306 PRINT
307 PRINT "TO PRINT THE PLAYING BOARD, TYPE 0 (ZERO) AS YOUR MOVE."
308 PRINT "THE PROGRAM WILL PRINT THE BOARD WITH YOUR MOVES INDI-"
309 PRINT "CATED WITH A (Y), THE MACHINE'S MOVES WITH AN (M), AND"
310 PRINT "UNUSED SQUARES WITH A ( ).  OUTPUT IS ON PAPER."
311 PRINT
312 PRINT "TO STOP THE PROGRAM RUN, TYPE 1 AS YOUR MOVE."
313 PRINT:PRINT
315 DIM X(64),L(76),M(76,4),Y(16)
320 FOR I = 1 TO 16
330 READ Y(I)
340 NEXT I
350 FOR I=1 TO 76
360 FOR J = 1 TO 4
370 READ M(I,J)
380 NEXT J
390 NEXT I
400 FOR I = 1 TO 64
410 LET X (I) =0
420 NEXT I
430 LET Z=1
440 PRINT "DO YOU WANT TO MOVE FIRST";
450 INPUT S$
460 IF LEFT$(S$,1)="N" THEN 630
470 IF LEFT$(S$,1)="Y" THEN 500
480 PRINT "INCORRECT ANSWER.  PLEASE TYPE 'YES' OR 'NO'.";
490 GOTO 450
500 PRINT " "
510 PRINT "YOUR MOVE";
520 INPUT J1
521 IF J1=1 THEN 2770
522 IF J1<>0 THEN 525
523 GOSUB 2550
524 GOTO 500
525 IF J1<111 THEN 2750
526 IF J1>444 THEN 2750
530 GOSUB 2500
540 LET K1=INT(J1/100)
550 LET J2=(J1-K1*100)
560 LET K2=INT(J2/10)
570 LET K3= J1 - K1*100 -K2*10
580 LET M=16*K1+4*K2+K3-20
590 IF X(M)=0 THEN 620
600 PRINT "THAT SQUARE IS USED, TRY AGAIN."
610 GOTO 500
620 LET X(M)=1
630 GOSUB 1640
640 J=1
650 I=1
660 IF J=1 THEN 720
670 IF J=2 THEN 790
680 IF J=3 THEN 930
690 I=I+1: IF I<=76 THEN 660
700 J=J+1: IF J<=3 THEN 650
710 GOTO 1300
720 IF L(I)<>4 THEN 690
730 PRINT "YOU WIN AS FOLLOWS";
740 FOR J=1 TO 4
750 LET M=M(I,J)
760 GOSUB 1570
770 NEXT J
780 GOTO 1490
790 IF L(I)<>15 THEN 690
800 FOR J=1 TO 4
810 LET M=M(I,J)
820 IF X(M)<>0 THEN 860
830 LET X(M)=5
840 PRINT "MACHINE MOVES TO";
850 GOSUB 1570
860 NEXT J
870 PRINT ", AND WINS AS FOLLOWS"
880 FOR J=1 TO 4
890 LET M=M(I,J)
900 GOSUB 1570
910 NEXT J
920 GOTO 1490
930 IF L(I)<>3 THEN 690
940 PRINT "NICE TRY. MACHINE MOVES TO";
950 FOR J=1 TO 4
960 LET M=M(I,J)
970 IF X(M)<>0 THEN 1010
980 LET X(M)=5
990 GOSUB 1570
1000 GOTO 500
1010 NEXT J
1020 GOTO 1300
1030 I=1
1040 LET L(I)=X(M(I,1))+X(M(I,2))+X(M(I,3))+X(M(I,4))
1050 LET L = L(I)
1060 IF L <2 THEN 1130
1070 IF L>=3 THEN 1130
1080 IF L>2 THEN 2230
1090 FOR J = 1 TO 4
1100 IF X(M(I,J))<>0 THEN 1120
1110 LET X(M(I,J))=1/8
1120 NEXT J
1130 I=I+1: IF I<=76 THEN 1040
1140 GOSUB 1640
1150 I=1
1160 IF L(I)=1/2 THEN 2360
1170 IF L(I)=1+3/8 THEN 2360
1180 I=I+1: IF I<=76 THEN 1160
1190 GOTO 1830
1200 LET Z = 1
1210 IF X(Y(Z))=0 THEN 1250
1220 LET Z=Z+1
1230 IF Z<>17 THEN 1210
1240 GOTO 1720
1250 LET M=Y(Z)
1260 LET X(M)=5
1270 PRINT "MACHINE MOVES TO";
1280 GOSUB 1570
1290 GOTO 500
1300 LET X=X
1310 I=1
1320 LET L(I)=X(M(I,1))+X(M(I,2))+X(M(I,3))+X(M(I,4))
1330 LET L=L(I)
1340 IF L<10 THEN 1410
1350 IF L>=11 THEN 1410
1360 IF L>10 THEN 2230
1370 FOR J=1 TO 4
1380 IF X(M(I,J))<>0 THEN 1400
1390 LET X(M(I,J))=1/8
1400 NEXT J
1410 I=I+1: IF I<=76 THEN 1320
1420 GOSUB 1640
1430 I=1
1440 IF L(I)=.5 THEN 2360
1450 IF L(I)=5+3/8 THEN 2360
1460 I=I+1: IF I<=76 THEN 1440
1470 GOSUB 2500
1480 GOTO 1030
1490 PRINT " "
1500 PRINT "DO YOU WANT TO TRY ANOTHER GAME";
1510 INPUT X$
1520 IF LEFT$(X$,1)="Y" THEN 400
1530 IF LEFT$(X$,1)="N" THEN 1560
1540 PRINT "INCORRECT ANSWER. PLEASE TYPE 'YES' OR 'NO'";
1550 GOTO 1510
1560 END
1570 LET K1=INT((M-1)/16)+1
1580 LET J2=M-16*(K1-1)
1590 LET K2=INT((J2-1)/4)+1
1600 LET K3=M-(K1-1)*16-(K2-1)*4
1610 LET M=K1*100+K2*10+K3
1620 PRINT M;
1630 RETURN
1640 FOR S=1 TO 76
1650 LET J1 = M(S,1)
1660 LET J2=M(S,2)
1670 LET J3=M(S,3)
1680 LET J4=M(S,4)
1690 LET L(S)=X(J1)+X(J2)+X(J3)+X(J4)
1700 NEXT S
1710 RETURN
1720 FOR I=1 TO 64
1730 IF X(I)<>0 THEN 1800
1740 LET X(I)=5
1750 LET M=I
1760 PRINT "MACHINE LIKES";
1770 GOSUB 1570
1780 PRINT " "
1790 GOTO 500
1800 NEXT I
1810 PRINT "THE GAME IS A DRAW."
1820 GOTO 1490
1830 FOR K=1 TO 18
1840 LET P=0
1850 FOR I=4*K-3 TO 4*K
1860 FOR J=1 TO 4
1870 LET P=P+X(M(I,J))
1880 NEXT J
1890 NEXT I
1900 IF P<4 THEN 1940
1910 IF P<5 THEN 1970
1920 IF P<9 THEN 1940
1930 IF P<10 THEN 1970
1940 NEXT K
1950 GOSUB 2500
1960 GOTO 1200
1970 LET S=1/8
1980 FOR I=4*K-3 TO 4*K
1990 GOTO 2370
2000 NEXT I
2010 LET S=0
2020 GOTO 1980
2030 DATA 1,49,52,4,13,61,64,16,22,39,23,38,26,42,27,43
2040 DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
2050 DATA 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38
2060 DATA 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56
2070 DATA 57,58,59,60,61,62,63,64
2080 DATA 1,17,33,49,5,21,37,53,9,25,41,57,13,29,45,61
2090 DATA 2,18,34,50,6,22,38,54,10,26,42,58,14,30,46,62
2100 DATA 3,19,35,51,7,23,39,55,11,27,43,59,15,31,47,63
2110 DATA 4,20,36,52,8,24,40,56,12,28,44,60,16,32,48,64
2120 DATA 1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61
2130 DATA 2,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62
2140 DATA 3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63
2150 DATA 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64
2160 DATA 1,6,11,16,17,22,27,32,33,38,43,48,49,54,59,64
2170 DATA 13,10,7,4,29,26,23,20,45,42,39,36,61,58,55,52
2180 DATA 1,21,41,61,2,22,42,62,3,23,43,63,4,24,44,64
2190 DATA 49,37,25,13,50,38,26,14,51,39,27,15,52,40,28,16
2200 DATA 1,18,35,52,5,22,39,56,9,26,43,60,13,30,47,64
2210 DATA 49,34,19,4,53,38,23,8,57,42,27,12,61,46,31,16
2220 DATA 1,22,43,64,16,27,38,49,4,23,42,61,13,26,39,52
2230 FOR J=1 TO 4
2240 IF X(M(I,J))<>1/8 THEN 2330
2250 LET X(M(I,J))=5
2260 IF L(I)<5 THEN 2290
2270 PRINT "LET'S SEE YOU GET OUT OF THIS:  MACHINE MOVES TO";
2280 GOTO 2300
2290 PRINT "YOU FOX.  JUST IN THE NICK OF TIME, MACHINE MOVES TO";
2300 LET M=M(I,J)
2310 GOSUB 1570
2320 GOTO 500
2330 NEXT J
2340 PRINT "MACHINE CONCEDES THIS GAME."
2350 GOTO 1490
2360 LET S=1/8
2370 IF I-INT(I/4)*4>1 THEN 2400
2380 LET A=1
2390 GOTO 2410
2400 LET A=2
2410 FOR J=A TO 5-A STEP 5-2*A
2420 IF X(M(I,J))=S THEN 2450
2430 NEXT J
2440 GOTO 2000
2450 LET X(M(I,J))=5
2460 LET M=M(I,J)
2470 PRINT "MACHINE TAKES";
2480 GOSUB 1570
2490 GOTO 500
2500 FOR I=1 TO 64
2510 IF X(I)<>1/8 THEN 2530
2520 LET X(I)=0
2530 NEXT I
2540 RETURN
2550 FOR XX=1 TO 9:PRINT:NEXT:FOR I=1 TO 4
2560 FOR J=1 TO 4
2562 FOR I1=1 TO J
2564 PRINT"   ";
2566 NEXT I1
2570 FOR K=1 TO 4
2600 LET Q=16*I+4*J+K-20
2610 IF X(Q)<>O THEN 2630
2620 PRINT"( )      ";
2630 IF X(Q)<>5 THEN 2650
2640 PRINT"(M)      ";
2650 IF X(Q)<>1 THEN 2660
2655 PRINT"(Y)      ";
2660 IF X(Q)<>1/8 THEN 2670
2665 PRINT"( )      ";
2670 NEXT K
2680 PRINT
2690 PRINT
2700 NEXT J
2710 PRINT
2720 PRINT
2730 NEXT I
2735 REM PRINT CHR$(12)
2740 RETURN
2750 PRINT"INCORRECT MOVE, RETYPE IT--";
2760 GOTO 520
2770 END


$ ./vintbas ../test/qubit.bas

                                 QUBIC

               CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY



DO YOU WANT INSTRUCTIONS? YES

THE GAME IS TIC-TAC-TOE IN A 4 X 4 X 4 CUBE.
EACH MOVE IS INDICATED BY A 3 DIGIT NUMBER, WITH EACH
DIGIT BETWEEN 1 AND 4 INCLUSIVE.  THE DIGITS INDICATE THE
LEVEL, ROW, AND COLUMN, RESPECTIVELY, OF THE OCCUPIED
PLACE. 

TO PRINT THE PLAYING BOARD, TYPE 0 (ZERO) AS YOUR MOVE.
THE PROGRAM WILL PRINT THE BOARD WITH YOUR MOVES INDI-
CATED WITH A (Y), THE MACHINE'S MOVES WITH AN (M), AND
UNUSED SQUARES WITH A ( ).  OUTPUT IS ON PAPER.

TO STOP THE PROGRAM RUN, TYPE 1 AS YOUR MOVE.


DO YOU WANT TO MOVE FIRST? YES
 
YOUR MOVE? 111
MACHINE MOVES TO 411 
YOUR MOVE? 0









   (Y)      ( )      ( )      ( )     

      ( )      ( )      ( )      ( )     

         ( )      ( )      ( )      ( )     

            ( )      ( )      ( )      ( )     



   ( )      ( )      ( )      ( )     

      ( )      ( )      ( )      ( )     

         ( )      ( )      ( )      ( )     

            ( )      ( )      ( )      ( )     



   ( )      ( )      ( )      ( )     

      ( )      ( )      ( )      ( )     

         ( )      ( )      ( )      ( )     

            ( )      ( )      ( )      ( )     



   (M)      ( )      ( )      ( )     

      ( )      ( )      ( )      ( )     

         ( )      ( )      ( )      ( )     

            ( )      ( )      ( )      ( )     



 
YOUR MOVE?


Towers of Hanoi
Code: [Select]
10 PRINT TAB(33);"TOWERS"
20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
30 PRINT:PRINT:PRINT
90 PRINT
100 REM*** INITIALIZE
110 DIM T(7,3)
120 E=0
130 FOR D=1 TO 7
140 FOR N=1 TO 3
150 T(D,N)=0
160 NEXT N
170 NEXT D
180 PRINT "TOWERS OF HANOI PUZZLE.": PRINT
200 PRINT "YOU MUST TRANSFER THE DISKS FROM THE LEFT TO THE RIGHT"
205 PRINT "TOWER, ONE AT A TIME, NEVER PUTTING A LARGER DISK ON A"
210 PRINT "SMALLER DISK.": PRINT
215 INPUT "HOW MANY DISKS DO YOU WANT TO MOVE (7 IS MAX)";S
220 PRINT
230 M=0
240 FOR Q=1 TO 7
250 IF Q=S THEN 350
260 NEXT Q
270 E=E+1
280 IF E>2 THEN 310
290 PRINT "SORRY, BUT I CAN'T DO THAT JOB FOR YOU.": GOTO 215
310 PRINT "ALL RIGHT, WISE GUY, IF YOU CAN'T PLAY THE GAME RIGHT, I'LL"
320 PRINT "JUST TAKE MY PUZZLE AND GO HOME.  SO LONG.": STOP
340 REM *** STORE DISKS FROM SMALLEST TO LARGEST
350 PRINT "IN THIS PROGRAM, WE SHALL REFER TO DISKS BY NUMERICAL CODE."
355 PRINT "3 WILL REPRESENT THE SMALLEST DISK, 5 THE NEXT SIZE,"
360 PRINT "7 THE NEXT, AND SO ON, UP TO 15.  IF YOU DO THE PUZZLE WITH"
365 PRINT "2 DISKS, THEIR CODE NAMES WOULD BE 13 AND 15.  WITH 3 DISKS"
370 PRINT "THE CODE NAMES WOULD BE 11, 13 AND 15, ETC.  THE NEEDLES"
375 PRINT "ARE NUMBERED FROM LEFT TO RIGHT, 1 TO 3.  WE WILL"
380 PRINT "START WITH THE DISKS ON NEEDLE 1, AND ATTEMPT TO MOVE THEM"
385 PRINT "TO NEEDLE 3."
390 PRINT: PRINT "GOOD LUCK!": PRINT
400 Y=7: D=15
420 FOR X=S TO 1 STEP -1
430 T(Y,1)=D: D=D-2: Y=Y-1
460 NEXT X
470 GOSUB 1230
480 PRINT "WHICH DISK WOULD YOU LIKE TO MOVE";:E=0
500 INPUT D
510 IF (D-3)*(D-5)*(D-7)*(D-9)*(D-11)*(D-13)*(D-15)=0 THEN 580
520 PRINT "ILLEGAL ENTRY... YOU MAY ONLY TYPE 3,5,7,9,11,13, OR 15."
530 E=E+1: IF E>1 THEN 560
550 GOTO 500
560 PRINT "STOP WASTING MY TIME.  GO BOTHER SOMEONE ELSE.": STOP
580 REM *** CHECK IF REQUESTED DISK IS BELOW ANOTHER
590 FOR R=1 TO 7
600 FOR C=1 TO 3
610 IF T(R,C)=D THEN 640
620 NEXT C: NEXT R
640 FOR Q=R TO 1 STEP -1
645 IF T(Q,C)=0 THEN 660
650 IF T(Q,C)<D THEN 680
660 NEXT Q
670 GOTO 700
680 PRINT "THAT DISK IS BELOW ANOTHER ONE.  MAKE ANOTHER CHOICE."
690 GOTO 480
700 E=0
705 INPUT "PLACE DISK ON WHICH NEEDLE";N
730 IF (N-1)*(N-2)*(N-3)=0 THEN 800
735 E=E+1
740 IF E>1 THEN 780
750 PRINT "I'LL ASSUME YOU HIT THE WRONG KEY THIS TIME.  BUT WATCH IT,"
760 PRINT "I ONLY ALLOW ONE MISTAKE.": GOTO 705
780 PRINT "I TRIED TO WARN YOU, BUT YOU WOULDN'T LISTEN."
790 PRINT "BYE BYE, BIG SHOT.":STOP
800 FOR R=1 TO 7
810 IF T(R,N)<>0 THEN 840
820 NEXT R
830 GOTO 880
835 REM *** CHECK IF DISK TO BE PLACED ON A LARGER ONE
840 IF D<T(R,N) THEN 880
850 PRINT "YOU CAN'T PLACE A LARGER DISK ON TOP OF A SMALLER ONE,"
860 PRINT "IT MIGHT CRUSH IT!": PRINT "NOW THEN, ";:GOTO 480
875 REM *** MOVE RELOCATED DISK
880 FOR V=1 TO 7: FOR W=1 TO 3
900 IF T(V,W)=D THEN 930
910 NEXT W: NEXT V
925 REM *** LOCATE EMPTY SPACE ON NEEDLE N
930 FOR U=1 TO 7
940 IF T(U,N)<>0 THEN 970
950 NEXT U
960 U=7: GOTO 980
965 REM *** MOVE DISK AND SET OLD LOCATION TO 0
970 U=U-1
980 T(U,N)=T(V,W): T(V,W)=0
995 REM *** PRINT OUT CURRENT STATUS
1000 GOSUB 1230
1018 REM *** CHECK IF DONE
1020 M=M+1
1030 FOR R=1 TO 7: FOR C=1 TO 2
1050 IF T(R,C)<>0 THEN 1090
1060 NEXT C: NEXT R
1080 GOTO 1120
1090 IF M<=128 THEN 480
1100 PRINT "SORRY, BUT I HAVE ORDERS TO STOP IF YOU MAKE MORE THAN"
1110 PRINT "128 MOVES.": STOP
1120 IF M<>2^S-1 THEN 1140
1130 PRINT:PRINT "CONGRATULATIONS!!":PRINT
1140 PRINT "YOU HAVE PERFORMED THE TASK IN";M;"MOVES."
1150 PRINT: PRINT "TRY AGAIN (YES OR NO)";: INPUT A$
1160 IF A$="NO" THEN 1390
1170 IF A$="YES" THEN 90
1180 PRINT: PRINT "'YES' OR 'NO' PLEASE";: INPUT A$: GOTO 1160
1230 REM *** PRINT SUBROUTINE
1240 FOR K=1 TO 7
1250 Z=10
1260 FOR J=1 TO 3
1270 IF T(K,J)=0 THEN 1330
1280 PRINT TAB(Z-INT(T(K,J)/2));
1290 FOR V=1 TO T(K,J)
1300 PRINT "*";
1310 NEXT V
1320 GOTO 1340
1330 PRINT TAB(Z);"*";
1340 Z=Z+21
1350 NEXT J
1360 PRINT
1370 NEXT K
1380 RETURN
1390 PRINT: PRINT "THANKS FOR THE GAME!": PRINT: END


$ ./vintbas ../test/tower.bas
                                 TOWERS
               CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY




TOWERS OF HANOI PUZZLE.

YOU MUST TRANSFER THE DISKS FROM THE LEFT TO THE RIGHT
TOWER, ONE AT A TIME, NEVER PUTTING A LARGER DISK ON A
SMALLER DISK.

HOW MANY DISKS DO YOU WANT TO MOVE (7 IS MAX)? 3

IN THIS PROGRAM, WE SHALL REFER TO DISKS BY NUMERICAL CODE.
3 WILL REPRESENT THE SMALLEST DISK, 5 THE NEXT SIZE,
7 THE NEXT, AND SO ON, UP TO 15.  IF YOU DO THE PUZZLE WITH
2 DISKS, THEIR CODE NAMES WOULD BE 13 AND 15.  WITH 3 DISKS
THE CODE NAMES WOULD BE 11, 13 AND 15, ETC.  THE NEEDLES
ARE NUMBERED FROM LEFT TO RIGHT, 1 TO 3.  WE WILL
START WITH THE DISKS ON NEEDLE 1, AND ATTEMPT TO MOVE THEM
TO NEEDLE 3.

GOOD LUCK!

          *                    *                    *
          *                    *                    *
          *                    *                    *
          *                    *                    *
     ***********               *                    *
    *************              *                    *
   ***************             *                    *
WHICH DISK WOULD YOU LIKE TO MOVE? 

« Last Edit: October 12, 2018, 11:51:15 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Vintage BASIC Interpreter
« Reply #1 on: October 13, 2018, 08:32:53 PM »
If a beginner programmer were to start off learning Vintage Basic, (like I did) moving on to a more relevant language should be easier.

I have been thinking about doing a web version of Script BASIC and after seeing Vintage Basic, I would offer a similar feature set. (no disk (samples only) or socket access) but everything else would be nice. (within limits) Maybe a e-mail your code as a way to save it or just copy / paste.

Control Solutions (Script BASIC commercial user) had SB running in a browser since 2003.


« Last Edit: October 14, 2018, 09:32:26 AM by John »

Offline AlyssonR

  • Advocate
  • Posts: 131
Re: Vintage BASIC Interpreter
« Reply #2 on: October 14, 2018, 02:33:03 AM »
Sounds good.