Richard,
Try the following:
: TEST ( -- )
doesit ( assume this returns when sound complete )
'ONSYSEXIT CALLS ( Execute System Exit Chain )
0 ExitProcess ;
Note that 'ONSYSEXIT CALLS ( Execute System Exit Chain ) should be
called by *any* SF app to properly cleanup.
DOS-CONSOLE OPEN-PERSONALITY is only required for a console app (as
is REQUIRES DOSBOX). Also, the phrase 0 5 DO I . 1000 Sleep DROP -1
+LOOP is not required at all and was simply to show the program was
shutting down.
Mike
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of Richard Owlett
Sent: Friday, December 19, 2003 4:00 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: A run once and exit EXE
Rick VanNorman wrote:
> A program using STARTER is by definition loading the console
> window environment. In this case, the cleanest and most proper
> way to exit is to use the word BYE .
>
> If you are writing a stand-alone program for Windows, which
> contains its own message loop, you should be using the
> ExitProcess technique. This type of application would be
> built by setting 'MAIN before saving the application.
>
> Bob's suggestion won't do as it might appear -- the playsound
> api doesn't return until the sound is finished.
>
> (preface all by "If I remember correctly...")
>
> Rick
>
I'll "raise your preface" by "I've written no Forth in 18 months".
First I'll try to describe what I'm attempting to do as I may be
coming at the problem from the wrong direction.
I am using Scilab version 2.7.2 ( open source competitor to Matlab )
to analyze/modify some audio files. It's origin is as a *nix based
application. The Windows port has no sound card support.
A "shell" command has been ported to the Windows version. It suffers
from the requirement that the invoked program must terminate before
the Scilab script may continue. The Windows supplied programs do not
close by themselves.
So I have 2 choices:
1. Anyone know of a Windows program which will play a WAV file and
close of it's own accord when done?
2. Write my own. Although this portion of the problem may not aim
at forth's strong points, a neophyte programmer was almost able to
solve the problem in less than an hour. Also, my eventual application
can make use of Forth's integer number crunching and easy prototyping
abilities.
Using "ExitProcess" as a keyword I searched the sFTalk archives and
arrived at http://www.forth.com/archive/sftalk/2002/1094.html .
Experimenting with the hint to use DOSBOX.f was productive.
My current code is
REQUIRES DOSBOX
library winmm.dll
4 import: mciSendString
create returnstring 256 allot
0 value returnvalue
: mcicommand returnstring 255 returnvalue mciSendString ;
: doesit z" play c:\atest\01tstsav.wav" mcicommand drop ;
: TEST ( -- )
DOS-CONSOLE OPEN-PERSONALITY
doesit
0 5 DO I . 1000 Sleep DROP -1 +LOOP (wait a second)
{ above is *TROUBLESOME!* }
0 ExitProcess ;
' TEST 'MAIN !
-1 THRESHOLD \ No Xref file
PROGRAM c:\atest\dos_box_based_playaudio
For short WAV files this is acceptable.
As Rick indicated, "the playsound api doesn't return until the sound
is finished".
Any suggestions as how I can have doesit wait until the sound has been
completed before exiting?
In an ideal world, there would never be a "visible" window and
"program" would close as soon as the audio had played.
thank you one and all and a MERRY CHRISTMAS to all.
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Fri Dec 19 2003 - 16:23:06 PST
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 07-Feb-2012. Archive updated nightly.