示例 3.
In this example, a script wants to open a DDE channel with Lotus Notes, whose executable name is stored in the variable mailprogram. If the program isnt running, the script starts it and loops, waiting until the programs startup is finished and it can establish a DDE channel. The loop includes Yield, so that the computer can spend time actually starting the other program:
time starttime
long hndl
SetPointer(HourGlass!)
//Try to establish a handle; SendMail is the topic.
hndl = OpenChannel("Notes","SendMail")
//If the program is not running, start it
IF hndl $#@60; 1 then
Run(mailprogram, Minimized!)
starttime = Now()
// Wait up to 2 minutes for Notes to load
// and the user to log on.
DO
//Yield control occasionally.
Yield()
//Is Notes active yet?
hndl = OpenChannel("Notes","SendMail")
// If Notes is active.
IF hndl $#@62; 0 THEN EXIT
LOOP Until SecondsAfter(StartTime,Now()) $#@62; 120