Hello All!
Well I just finished another exercise project form the book, "Beginner's Guide to Dark Basic," and again need help. The project simulates a jukebox being played. When I run the compiler though, I made a syntax error somewhere. If someone could try and find my error, that would be great.
Rem Project: The MusicJukebox Program
Rem Created: Monday, March 12, 2012
Rem Designer: Andrew D. South
Rem ***** Main Source File *****
`The files and Names of the songs (May have to change to .mid) (CHANGE TO MID CODE WORD)
DATA "Songs\song1.mp3","Battle Star Galactica"
DATA "Songs\song2.mp3","Star Trek TNG"
DATA "Songs\song3.mp3","Doctor Who"
DATA "Songs\song4.mp3","The Flintstones"
DATA "Songs\song5.mp3","Frosty the Snowman"
DATA "Songs\song6.mp3","God rest ye"
DATA "Songs\song7.mp3","O Holy Night"
DATA "Songs\song8.mp3","Theme from Jaws"
DATA "Songs\song9.mp3","Jingle Bells"
DATA "Songs\song10.mp3","Mission Impossible"
DATA "Songs\song11.mp3","Mister Ed"
DATA "Songs\song12.mp3","Outerlimits"
DATA "Songs\song13.mp3","Star Wars"
DATA "Songs\song14.mp3","Star Trek Voyager"
DATA "Songs\song15.mp3","What Child is This"
DATA "titlemusic.mp3","CD AUDIO"
`some global arrays for storing key information
DIM songtitle$(17)
DIM filename$(17)
DIM selected(1)
DIM maxsongs(1)
SYNC ON
SYNC RATE 30
maxsong(1) = 17
LOADALLMUSIC()
LOAD BITMAP "images\backdrop.bmp"
SYNC
SYNC
selected(1) = 1
DISPLAYTITLES()
`Checking and looping with the ESC key (ASCII value 27)
WHILE INKEY$() <> CHR$(27)
`Checking the downkey
IF DOWNKEY()=1
WHILE DOWNKEY()= 1
ENDWHILE
selected(1) = selected(1) + 1
IF selected(1) > maxsongs(1) THEN selected(1) = 1
DISPLAYTITLES()
ENDIF
`Checking the upkey
IF UPKEY()=1
WHILE UPKEY()= 1
ENDWHILE
selected(1) = selected(1) - 1
IF selected(1) < 1 THEN selected(1) = maxsongs(1)
DISPLAYTITLES()
ENDIF
`Checking the Space bar (ASCII value 32)
IF INKEY$() = CHR$(32)
IF MUSIC EXIST(1)
STOP MUSIC (1)
ENDIF
ENDIF
`Checking the P key
IF INKEY$() = "P" OR inkey$()="p"
IF MUSIC EXIST(1) = 1 THEN PAUSE MUSIC 1
ENDIF
`Checking the R key
IF INKEY$() = "R" OR INKEY$()="r"
WHILE INKEY$() = "R" OR inkey$()="r"
ENDWHILE
RESUME MUSIC 1
ENDIF
`Checking the ENTER key (ASCII value 13
IF INKEY$() = CHR$(13)
selector = selected(1)
IF filename$(selector) = "CDAUDIO"
SYNC
SYNC
IF MUSIC EXIST(1)
IF MUSIC PLAYING(1) THEN STOP MUSIC 1
DELETE MUSIC 1
ENDIF
LOAD CDMUSIC 1,1
IF MUSIC EXIST(1) THEN PLAY MUSIC 1
ELSE
IF MUSIC EXIST(1)
IF MUSIC PLAYING(1) THEN STOP MUSIC 1
DELETE MUSIC 1
ENDIF
LOAD MUSIC filename$(selector),1
PLAY MUSIC 1
ENDIF
ENDIF
`checking to see if the mouse was clicked over a song
IF MOUSECLICK()=1
WHILE MOUSECLICK()=1
SYNC
ENDWHILE
newsong= GETNEWSONGNAME()
IF newsong <> 0
selected(1) = newsong
DISPLAYTITLES()
ENDIF
ENDIF
SYNC
ENDWHILE
IF MUSIC EXIST(1)=1
STOP MUSIC 1
ENDIF
END
`sets all the music variables
FUNCTION LOADALLMUSIC() `(CHANGE TO MID)
FOR count = 1 TO maxsongs(1)
READ mp3files$
filename$(count) = midfile$
READ songname$
songtitle$(count) = songname$
NEXT count
ENDFUNCTION
`display all the music titles
FUNCTION DISPLAYTITLES
white = rgb(255,255,255)
black = rgb(0,0,0)
blue = rgb(0,0,255)
yellow = rgb(255,255,0)
SET TEXT OPAQUE
FOR count = 1 TO maxsongs(1)
IF count = selected(1)
INK yellow,blue
TEXT 425,75+((count-1)*16),songtitle$(count)
ENDIF
NEXT count
ENDFUNCTION
`checks the mouse cursor to see if it is over a new song
FUNCTION GETNEWSONGNAME()
xpos = MOUSEX();
ypos = MOUSEY();
IF xpos <425 THEN EXITFUNCTION 0
IF ypos <75 THEN EXITFUNCTION 0
IF xpos > 611 THEN EXITFUNCTION 0
IF ypos > 75+maxsongs(1)*16 THEN EXITFUNCTION 0
flag = 0
FOR count = 1 TO maxsongs(1)
ymin = 75+((count-1)*16);
Ymax = 75+((count)*16);
IF Ypos > Ymin AND Ypos < Ymax THEN flag = count
NEXT count
ENDFUNCTION flag
When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!