I've written quite a few Delphi apps with no real problems, but my latest project has me stumped. I think it's because of too many years using linear programming languages.
It's quite complicated, but I'll try and be as brief as possible...
Essentially, in my project, I create a list of WAV files in a directory and play them all randomly. When all have been played, I jumble them up and play them again. Repeat ad infinitum.
At specific times in the hour, a single WAV file from a different folder must be played - say 10 minutes past each hour (let's call this an 'event').
I have a Timer called every 500ms which updates the on-screen clock and checks to see if an event is due.
A event can be 'important' or 'non-important'.
Important events fire immediately at the time specified, stopping any currently playing WAV file. Non-important events will wait until the currently playing WAV file has finished before it fires.
All of the above is easy enough. The problem I am having is that I'm calling a main loop procedure to play each WAV file on the list using a Repeat..Until. If this main loop is exited, the program ends.
While playing a WAV, I wait until each one has finished before the next one is played using:
// Start WAV Playing
Repeat
Application.ProcessMessages;
Until (PlayNextWAV = True) Or (ProgExit = True);
// Here Is Never Reached
The problem is that after the first WAV is played, even though PlayNextWAV is set to True, the program doesn't drop down to lines immediately following it. In fact, if I put a breakpoint on the Until line, nothing happens and the program doesn't stop, so program control isn't really trapped in the Repeat..Until.
In a nutshell, with languages I'm used to, you always know where the Program Counter is. With Delphi, I'm no longer sure.
So, what's the 'proper' way to do what I'm trying to do?
Thanks in advance...
TB
It's quite complicated, but I'll try and be as brief as possible...
Essentially, in my project, I create a list of WAV files in a directory and play them all randomly. When all have been played, I jumble them up and play them again. Repeat ad infinitum.
At specific times in the hour, a single WAV file from a different folder must be played - say 10 minutes past each hour (let's call this an 'event').
I have a Timer called every 500ms which updates the on-screen clock and checks to see if an event is due.
A event can be 'important' or 'non-important'.
Important events fire immediately at the time specified, stopping any currently playing WAV file. Non-important events will wait until the currently playing WAV file has finished before it fires.
All of the above is easy enough. The problem I am having is that I'm calling a main loop procedure to play each WAV file on the list using a Repeat..Until. If this main loop is exited, the program ends.
While playing a WAV, I wait until each one has finished before the next one is played using:
// Start WAV Playing
Repeat
Application.ProcessMessages;
Until (PlayNextWAV = True) Or (ProgExit = True);
// Here Is Never Reached
The problem is that after the first WAV is played, even though PlayNextWAV is set to True, the program doesn't drop down to lines immediately following it. In fact, if I put a breakpoint on the Until line, nothing happens and the program doesn't stop, so program control isn't really trapped in the Repeat..Until.
In a nutshell, with languages I'm used to, you always know where the Program Counter is. With Delphi, I'm no longer sure.
So, what's the 'proper' way to do what I'm trying to do?
Thanks in advance...
TB