While there is no built-in command to run an application synchronously, you can resort to using DOS (remember DOS?) to accomplish the same thing:The idea is to use LabTalkTM to launch a batch file and then run a loop to 'watch' your system for a specific event. The DOS batch file synchronously runs your application with the START command and then creates the event that your script is watching for.
Origin Professional users have an easier time doing this since they can use the File Utilities Module (FUM) to read or write any kind of file, while Origin Standard users need to find some command that can read external files. Aside from importing-related commands, there is one object which allows reading from (and writing to) a file: the INI object.
Here's an outline of what to do:
- Create the batch file in Notepad
START /W "C:\Program Files\My Application.EXE"
ECHO [message] > C:\DONE.INI
ECHO new=Completed normally >> C:\DONE.INI
- Save the file
In this case we'll call it C:\Program Files\LAUNCH.BAT
- Run your script file
ini.get.filename$="C:\DONE.INI";
ini.message.new$=waiting;
run -e "C:\Program Files\LAUNCH.BAT";
for(done=0;done<1 ; ) {
%A=ini.message.new$;
if("%A"=="Completed normally") done=1;
}
ini.message.new$=None;
// remainder of script goes here ...
The script begins by making sure the Key value (new) in the [message] section of DONE.INI is set to "waiting".
Then the batch file is started which launches your application and Waits for it to complete.
After your application completes, the batch file creates DONE.INI (or overwrites) with the Key value 'new' set to "Completed normally".
This is just what the for loop in the script has been waiting for. Your script can now continue. (In this case I also set the 'new' Key to "None".)
You can create a PIF file that will close the DOS box created by LAUNCH.BAT by right-clicking on the DOS icon in the upper left of the DOS box and selecting Properties. Check the 'Close on Exit' box and OK out of the dialog.[This message has been edited by Greg (edited 09-14-99).]