Hi Tony,
Yeah, Lookup stores a list of constants at compile time, these can not be changed at a runtime. Instead you could use an array and a couple of index variables pointing into this array. Something like
Code:
PlayListMaximumLength CON 128
PlayList VAR BYTE[PlayListMaximumLength]
PlayPointer VAR BYTE
AddPointer VAR BYTE
Song VAR BYTE
AddPointer = 0 'Start adding songs from beginning of list
PlayPointer = 0 'Start playing songs from beginning of list
' Initilise playlist.
Song = 3 : Gosub AddSong
Song = 3 : Gosub AddSong
Song = 6 : Gosub AddSong
Song = 1 : Gosub AddSong
Song = 1 : Gosub AddSong
Song = 1 : Gosub AddSong
Song = 0 : Gosub Addsong ' Song=0 indicates end of list.
PlaySong:
While PlayList[PlayPointer] <> 0
' Do your thing here.
' Play the song.
' Check user inputs and GOSUB routines to add or manipulate the playlist.
PlayPointer = PlayPointer + 1 'Next song in list.
WEND
PlayPointer = 0 'Start over.
Goto PlaySong
AddSong:
PlayList[AddPointer] = Song
AddPointer = AddPointer + 1
If AddPointer = (PlayListMaximumLength - 1) THEN AddPointer = 0 'Wrap around and start over at the beginning of the list.
RETURN
Completely untested but illustrates one possible aproach. Another is to use the EEPROM (data/read/write) or even the program memory (readcode/writecode) to store and retreive the playlist, that way you can have it persistant.
/Henrik.
Bookmarks