Hello,
I have a book called "SS Advanced Computer Programs in Basic" and there is a program called "Horse". The program has 5 horses and they each race, and a random horse wins the race everytime.
I have copied each line and the program wont run, there is many errors and I don't know why there is errors since I copied it from the programming book.
Here is the code :
SmalBasic shows that the first error is on line 70, while Libertybasic shows that the first error is on line 50. And there are more errors. I am currently using Liberty Basic.Code:10 rem * press space bar to start the race or press 'M' key 20 rem * to have a horse die during the race 30 cls:print chr$(23);:input "press enter to start the race ";A$:CLS 40 DIM A(15):goto 250 50 cls:for A=1 to 14:read A(A):next a:for B=1 to 7:if B(B)<>2 then B(B)=0:next B 60 data 14,0,14,6,14,12,14,18,14,24,14,30,14,36 70 X=120:for Y=0 to 40 step 2:set(X,Y):next Y 80 for c=1 to 13 step 2:X=A(C):Y=A(C+1):gosub 390:next C 90 F=0:for C=1 to 7:print@F,C:F=F+128:next C 100 print @916, "get set . . .!"; 110 for X=1 to 2500:next X:print @916,"and they're off!!"; 120 for C=1 to 13 step 2 130 V=C:gosub 310:if B(M)=1 goto 170 140 if M=R3 and A(C)=R4 and B(M)<>2 then B(M)=1:goto 520 150 if B(M)=1 goto 170 160 W=rnd(2):if W=2 then A(C)=A(C)+3 170 next C 180 for V=1 to 13 step 2:gosub 310:X=A(V):Y=A(V+1):if B(M)=1 goto 190else gosub 390 190 next V 200 goto 120 210 for R=60 to 828 step 64:print@R,"*";:next R 220 print@916,"the race is over!!!";:for X=1 to 1000:next X 230 for X=1 to 1000:next X 240 cls:for P=1 to 250:next P 250 cls:print chr$(23);"W I N N E R:" print "H O R S E # ";M 260 restore 270 E$=inkey$ 280 if E$=" " then clear:dim A(15):goto 50 290 if E$="M" then clear:dim A(15):goto 470 300 for P=1 to 250:next P:goto 240 310 if V=1 then M=1 320 if V=3 then M=2 330 if V=5 then M=3 340 if V=7 then M=4 350 if V=9 then M=5 360 if V=11 then M=6 370 if V=13 then M=7 380 return 390 set(X,Y):set(X-1,Y) 400 for Z=X-7 to X-1:set(Z,Y+1):next Z 410 set(X-8,Y+2):set(X-1,Y+2) 420 reset(X-3,Y):reset(X-4,Y) 430 reset(X-8,Y+1):reset(X-9,Y+1):reset(X-10,Y=1) 440 reset(X-4,Y+2) 450 if X>=120 gosub 310:goto 210 460 return 470 R3=rnd(7):R4=rnd(50)+14 480 R=14 490 if R4=R goto 510 500 R=R+3:if R>70 goto 470 else goto 490 510 goto 50 520 X=A(C):Y=A(C+1) 530 reset(X,Y):reset(X-1,Y) 540 for B5=X-8 to X:reset(B5,Y+1):next B5 550 for B5=X-9 to X:reset(B5,Y+2):next B5 560 set (X-2,Y+1):set(X-9,Y=1) 570 for G=X-8 to X-2:set(G,Y+2):next G 580 set (X,Y+3):set(X-1,Y+3) 590 goto 150
Help me please.
Thanks.
Kidcash.
Last edited by kidcash; 01-29-2008 at 06:32 AM.
It would be great if you posted the errors.
There's different BASIC-dialects. Have you checked that the interpreter or compiler you're using for interpreting/compiling is made for the same dialect as in the book you have?
And by the way, have you thought about using another more modern language, than BASIC? There's a lot of good alternatives.
Ok well i tried the debug mode and here is where it found errors :
Line 50 - Syntax Error
Line 90 - Syntax Error
Line 130 - Syntax Error
Line 200 - Syntax Error
Line 240 - Syntax Error
Line 270 - Syntax Error
Line 310 - Syntax Error
Line 350 - Syntax Error
Line 390 - Syntax Error
Line 430 - Syntax Error
Line 470 - Syntax Error
Line 510 - Syntax Error
Line 550 - Syntax Error
Line 590 - Syntax Error
I found this in the book :
"all the programs in this book here were written and tested on a TRS-80 16k level II Computer using level II Basic"
Last edited by kidcash; 01-29-2008 at 11:36 AM.
That's not much information your interpreter/compiler is giving you, now I know why you're having problems in fixing it.
Did you check the dialect of the BASIC in the book, and the interpreter/compiler you're using. I still think it could be the problem.
I tried liberty basic here is what errors it gives me :
Also this is what I found in the book -Code:D:\Program Files\FreeBASIC>fbc examples/horse.bas examples/horse.bas(1) error 135: Only valid in -lang deprecated or qb in '10 rem * press space bar to start the race or press 'M' key' examples/horse.bas(2) error 135: Only valid in -lang deprecated or qb in '20 rem * to have a horse die during the race' examples/horse.bas(3) error 135: Only valid in -lang deprecated or qb in '30 cls :print chr$(23);:input "press enter to start the race ";A$:CLS' examples/horse.bas(3) error 137: Suffixes are only valid in -lang deprecated or qb, found 'A' in '30 cls:print chr$(23);:input "press enter to start the race "; A$:CLS' examples/horse.bas(4) error 135: Only valid in -lang deprecated or qb in '40 DIM A(15):goto 250' examples/horse.bas(5) error 135: Only valid in -lang deprecated or qb in '50 cls :for A=1 to 14:read A(A):next a:for B=1 to 7:if B(B)<>2 then B(B)=0:next B' examples/horse.bas(5) error 49: Expected scalar counter, before '=' in '50 cls:f or A=1 to 14:read A(A):next a:for B=1 to 7:if B(B)<>2 then B(B)=0:next B' examples/horse.bas(5) error 67: Array not dimensioned, before '(' in '50 cls:for A=1 to 14:read A(A):next a:for B=1 to 7:if B(B)<>2 then B(B)=0:next B' examples/horse.bas(5) error 97: NEXT without FOR, found ':' in '50 cls:for A=1 t o 14:read A(A):next a:for B=1 to 7:if B(B)<>2 then B(B)=0:next B' examples/horse.bas(5) error 41: Variable not declared, B in '50 cls:for A=1 to 1 4:read A(A):next a:for B=1 to 7:if B(B)<>2 then B(B)=0:next B' examples/horse.bas(5) error 123: Too many errors, exiting
"I found this in the book :
"all the programs in this book here were written and tested on a TRS-80 16k level II Computer using level II Basic"
So it uses Level II Basic? Where can I find a compiler i've searched everywhere but no compiler states what dialect it's for![]()
It seems like you're working with a very old book, and it seems like the book works with a very old computer and BASIC-dialect. I think you should find a more modern language to learn, at least just another BASIC-dialect.
I found some information on the old TRS-80 and the BASIC-dialect, though.
Mike's TRS-80 Model I Level II BASIC Page
OLD-COMPUTERS.COM : The Museum
The problem you're having is that BASIC is not "a language". It is a family of languages, each slightly different from the others. As a result, the code in your book may be perfectly good TRS-BASIC, but broken for every other BASIC compiler in existence. It is likely that you would have to find an old TRS-80 computer to get the compiler.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks