Code: Select all
IF INKEY$ <> "" GOTO notitle
PLAY "MST170o1e8o0b8o1e8"
IF INKEY$ <> "" GOTO notitle
PLAY "e8e4f#8g4f#8"
What I'm wondering is if there is a better way to do this as I move the code over to FreeBasic?
Thanks,
Dave
Code: Select all
IF INKEY$ <> "" GOTO notitle
PLAY "MST170o1e8o0b8o1e8"
IF INKEY$ <> "" GOTO notitle
PLAY "e8e4f#8g4f#8"
Code: Select all
dim as string music(0 to 99) ' as many as needed
dim as LongInt cnt = 0 ' just to be on the save side
' first fill the array with strings, then ...
do
' you should allways check for array bounds
if cnt > 99 then cnt = 0 ' depends on array size !!
play music[cnt] ' play one after another (from array)
if inkey <> "" then exit do ' exit when keypress detected
cnt += 1 ' increment counter
loop
.... ' your code again
Code: Select all
'play emulation :-)
sub play(notes as string)
dim as integer i
for i = 1 to len(notes)
print mid(notes, i, 1);
sleep 100,1
next
print
end sub
dim as integer i, numLines
dim as string music(0 to 99)
'read and store music data
read numlines
for i = 0 to numLines-1
read music(i)
next
'play music lines until key press
for i = 0 to numLines-1
if (inkey() <> "") then exit for
play music(i)
next
data 6 'numLines
data "MST170o1e8o0b8o1e8"
data "e8e4f#8g4f#8"
data "this is not music"
data "this is just text"
data "bye, bye"
data "end......."