Dir Help Opening Music!
Author |
Message |
B-Man 31
|
Posted: Tue Oct 27, 2009 8:41 pm Post subject: Dir Help Opening Music! |
|
|
ok, im trying to load songs from a folder using the Dir functions, but i cant seem to get it to actually take the string it reads and change it to a different variable. so i can use it later on. i dont know how much sense im making here so maybe it would be easier if you looked at the code below. Thanks for any help!
Turing: |
import GUI
var songNum, stream, songList, select : int
var file, songName : string
proc chooseSong (line : int)
Music.PlayFileReturn (songName (line ))
select := line
end chooseSong
proc getSongs
stream := Dir.Open ("Sounds/Music")
assert stream > 0
loop
file := Dir.Get (stream )
file := songName
exit when file = ""
end loop
Dir.Close (stream )
for i : 1 .. songNum
GUI.AddLine (songList, songName (i ) (1 .. * - 4))
end for
end getSongs
getSongs
songList := GUI.CreateTextBoxChoice (20, 130, 360, 105, 0, 0, chooseSong )
loop
exit when GUI.ProcessEvent
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Oct 27, 2009 9:18 pm Post subject: RE:Dir Help Opening Music! |
|
|
could you explain what's going on in this loop?
code: |
loop
file := Dir.Get (stream)
file := songName
exit when file = ""
end loop
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
B-Man 31
|
Posted: Tue Oct 27, 2009 9:31 pm Post subject: Re: RE:Dir Help Opening Music! |
|
|
Tony @ Tue Oct 27, 2009 9:18 pm wrote: could you explain what's going on in this loop?
code: |
loop
file := Dir.Get (stream)
file := songName
exit when file = ""
end loop
|
in that loop its supposed to read first folder and take the filename and have the same as the songName string so ic an play it.
this is the part that doesnt seem to work. |
|
|
|
|
|
Tony
|
Posted: Tue Oct 27, 2009 10:04 pm Post subject: RE:Dir Help Opening Music! |
|
|
What is the value of songName, and where is it set?
What is the value of file when the loop exists? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
B-Man 31
|
Posted: Wed Oct 28, 2009 7:01 am Post subject: Re: RE:Dir Help Opening Music! |
|
|
Tony @ Tue Oct 27, 2009 10:04 pm wrote: What is the value of songName, and where is it set?
What is the value of file when the loop exists?
songName doesnt have a value and file should be a string value of the first file in the folder (this way i can use the songname to play the music since it the exact file name) |
|
|
|
|
|
TheGuardian001
|
Posted: Wed Oct 28, 2009 7:38 am Post subject: Re: RE:Dir Help Opening Music! |
|
|
B-Man 31 @ Wed Oct 28, 2009 7:01 am wrote:
songName doesnt have a value and file should be a string value of the first file in the folder (this way i can use the songname to play the music since it the exact file name)
code: |
file := Dir.Get(stream)
file := songName
|
If songName has no value, why are you assigning it to file? file was the value of the first file in the directory, then you set it to songName, which is nothing. Perhaps you wanted that the other way around? |
|
|
|
|
|
B-Man 31
|
Posted: Wed Oct 28, 2009 10:06 am Post subject: Re: Dir Help Opening Music! |
|
|
Thanks for both your help, i got it to wokr, the error was stupidity and both of you helped me point it out, thanks! |
|
|
|
|
|
|
|