Author Topic: exercise error  (Read 2630 times)

0 Members and 1 Guest are viewing this topic.

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
exercise error
« on: December 16, 2020, 06:57:12 pm »

a new exercise that gives an error in line 6


called by gosub
and after pressing enter a second error in line 14

Code: QB64: [Select]
  1. COLOR 0, 2: CLS: COLOR 14, 4: PRINT SPACE$(240)
  2. LOCATE 2, 30: PRINT "****SCELTA MULTIPLA***";
  3. LOCATE 4, 1: PRINT STRING$(80, "_");: COLOR 0, 2
  4. LOCATE 10, 25: PRINT "Ti stai divertendo con questo programma?";
  5.     PLAY "L62 04 T250 D G G D G# A A 03 D G G D A A# A# 02 D G G D A# B B"
  6.     LOCATE 13, 29, 1: PRINT "<S>i.  <N>o.  <F>orse";
  7.     LOCATE 15, 40
  8.     r$ = UCASE$(INPUT$(1)) 'ottiene input dall'utente
  9.     ON INSTR("SNF", r$) GOSUB Si, No, Forse 'salta a si,no o forse
  10. LOOP WHILE risposta$ = ""
  11. LOCATE 18, 40 - (LEN(risposta$) \ 2)
  12. PRINT risposta$;
  13. PLAY tono$
  14.  
  15. Forse:
  16. tono$ = "T255 L15 01 A D C E F A 02 D E F A E C"
  17. risposta$ = "il tuo suono e' indeciso!"
  18.  
  19. Si:
  20. tono$ = "L8 02 T240 D.. E. P16 ML A G B."
  21. risposta$ = "il tuo suono e' assai positivo!"
  22.  
  23. No:
  24. tono$ = "T200 0314 G C D E L2 F L4 E C L2 D P64 D L4 E L1C"
  25. risposta$ = "il tuo suono e veramente negativo!"
  26.  

Is it possible to learn from this book that I bought on paper if there has always been an error in the examples?
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: exercise error
« Reply #1 on: December 16, 2020, 07:03:12 pm »
Those look like 0's (Zero) in the PLAY statements.  That would give an error.  Should probably be the letter O instead.  Change them to like:    PLAY "L62 o4 T250 D G G D G# A A o3 D G G D A A# A# o2 D G G D A# B B" and see if it goes away.

- Dav

Edit:  I changed them and it seems to run now.  Sometimes a Capitol O and 0 (zero) looks alike on paper.  I made them a small o in the code so you can see what was changed.

Code: QB64: [Select]
  1. COLOR 0, 2: CLS: COLOR 14, 4: PRINT SPACE$(240)
  2. LOCATE 2, 30: PRINT "****SCELTA MULTIPLA***";
  3. LOCATE 4, 1: PRINT STRING$(80, "_");: COLOR 0, 2
  4. LOCATE 10, 25: PRINT "Ti stai divertendo con questo programma?";
  5.     PLAY "L62 o4 T250 D G G D G# A A o3 D G G D A A# A# 02 D G G D A# B B"
  6.     LOCATE 13, 29, 1: PRINT "<S>i.  <N>o.  <F>orse";
  7.     LOCATE 15, 40
  8.     r$ = UCASE$(INPUT$(1)) 'ottiene input dall'utente
  9.     ON INSTR("SNF", r$) GOSUB Si, No, Forse 'salta a si,no o forse
  10. LOOP WHILE risposta$ = ""
  11. LOCATE 18, 40 - (LEN(risposta$) \ 2)
  12. PRINT risposta$;
  13. PLAY tono$
  14.  
  15. Forse:
  16. tono$ = "T255 L15 o1 A D C E F A o2 D E F A E C"
  17. risposta$ = "il tuo suono e' indeciso!"
  18.  
  19. Si:
  20. tono$ = "L8 o2 T240 D.. E. P16 ML A G B."
  21. risposta$ = "il tuo suono e' assai positivo!"
  22.  
  23. No:
  24. tono$ = "T200 0314 G C D E L2 F L4 E C L2 D P64 D L4 E L1C"
  25. risposta$ = "il tuo suono e veramente negativo!"
  26.  
  27.  
« Last Edit: December 16, 2020, 07:09:39 pm by Dav »

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: exercise error
« Reply #2 on: December 16, 2020, 07:34:21 pm »
Those look like 0's (Zero) in the PLAY statements.  That would give an error.  Should probably be the letter O instead.  Change them to like:    PLAY "L62 o4 T250 D G G D G# A A o3 D G G D A A# A# o2 D G G D A# B B" and see if it goes away.

- Dav

Edit:  I changed them and it seems to run now.  Sometimes a Capitol O and 0 (zero) looks alike on paper.  I made them a small o in the code so you can see what was changed.

Code: QB64: [Select]
  1. COLOR 0, 2: CLS: COLOR 14, 4: PRINT SPACE$(240)
  2. LOCATE 2, 30: PRINT "****SCELTA MULTIPLA***";
  3. LOCATE 4, 1: PRINT STRING$(80, "_");: COLOR 0, 2
  4. LOCATE 10, 25: PRINT "Ti stai divertendo con questo programma?";
  5.     PLAY "L62 o4 T250 D G G D G# A A o3 D G G D A A# A# 02 D G G D A# B B"
  6.     LOCATE 13, 29, 1: PRINT "<S>i.  <N>o.  <F>orse";
  7.     LOCATE 15, 40
  8.     r$ = UCASE$(INPUT$(1)) 'ottiene input dall'utente
  9.     ON INSTR("SNF", r$) GOSUB Si, No, Forse 'salta a si,no o forse
  10. LOOP WHILE risposta$ = ""
  11. LOCATE 18, 40 - (LEN(risposta$) \ 2)
  12. PRINT risposta$;
  13. PLAY tono$
  14.  
  15. Forse:
  16. tono$ = "T255 L15 o1 A D C E F A o2 D E F A E C"
  17. risposta$ = "il tuo suono e' indeciso!"
  18.  
  19. Si:
  20. tono$ = "L8 o2 T240 D.. E. P16 ML A G B."
  21. risposta$ = "il tuo suono e' assai positivo!"
  22.  
  23. No:
  24. tono$ = "T200 0314 G C D E L2 F L4 E C L2 D P64 D L4 E L1C"
  25. risposta$ = "il tuo suono e veramente negativo!"
  26.  
  27.  


thanks you were right changing the 0 to or works perfectly
thanks dav
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione