Closed Thread
Results 1 to 7 of 7

Thread: Error on My Basic Program Copied from Programming Book

  1. #1
    kidcash is offline Newbie
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0

    Error on My Basic Program Copied from Programming Book

    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 :

    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
    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.

    Help me please.

    Thanks.
    Kidcash.
    Last edited by kidcash; 01-29-2008 at 06:32 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    v0id is offline Retired
    Join Date
    Apr 2007
    Posts
    2,937
    Blog Entries
    3
    Rep Power
    42
    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.

  4. #3
    kidcash is offline Newbie
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0
    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.

  5. #4
    v0id is offline Retired
    Join Date
    Apr 2007
    Posts
    2,937
    Blog Entries
    3
    Rep Power
    42
    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.

  6. #5
    kidcash is offline Newbie
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0
    I tried liberty basic here is what errors it gives me :

    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
    Also this is what I found in the book -

    "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

  7. #6
    v0id is offline Retired
    Join Date
    Apr 2007
    Posts
    2,937
    Blog Entries
    3
    Rep Power
    42
    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

  8. #7
    Join Date
    Jul 2006
    Posts
    16,479
    Blog Entries
    75
    Rep Power
    143
    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.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Best C programming book
    By PETTE in forum The Lounge
    Replies: 3
    Last Post: 10-28-2010, 02:17 PM
  2. Replies: 3
    Last Post: 07-13-2010, 02:39 PM
  3. First Programming Book
    By penguin in forum The Lounge
    Replies: 6
    Last Post: 05-22-2009, 06:40 PM
  4. Programming book
    By ultimatefighter7 in forum C and C++
    Replies: 5
    Last Post: 08-21-2008, 09:57 AM
  5. Basic Address Book project with out using database.
    By rs loader in forum Visual Basic Programming
    Replies: 1
    Last Post: 09-06-2007, 10:49 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts