programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: A run once and exit EXE

From: Richard Owlett <rcowlett_at_atlascomm.net>
Date: Fri, 19 Dec 2003 17:59:52 -0600

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
----------------------------------------------------------------------
Received on Fri Dec 19 2003 - 15:59:03 PST

This archive was generated by hypermail 2.2.0 : Wed Nov 19 2008 - 03:04:21 PST