The real answer to this question is "By understanding the nature of the first application". Depending on that nature, you can either always be sure, or never be sure.
Simon doesn't specify the environment his script runs in, so I'm going to assume it's all native MapInfo (i.e. workspaces or other MapBasic applications). MapBasic applications come in two flavors: "scripts" and "tools". Which flavor depends upon the actions performed in a subroutine (called "Main") built into every application. When a workspace or MapBasic application issues a Run Mapbasic Application command, MapInfo takes control away from the "outer" application and gives it to the "inner" one. The "inner" application runs its Sub Main, then MapInfo returns control to the "outer" application. A "script" runs some commands from its Sub Main and terminates. If your program gets to the next line of code after the Run Mapbasic Application command that invoked the first application, you can be sure it's done. A "tool"'s Sub Main installs some custom commands in menus and toolbars. The application goes to sleep, waiting for the user to invoke the custom commands. Usually, one of these custom commands unloads the application. The application isn't "finished" until the user invokes the command that unloads it. There are some DDE tricks that you can use to test if a "tool" has been unloaded by the user, or if a particular task has completed, or to force it to unload, but those mechanisms depend entirely on the application (i.e. your first application) you want to test for or force closed. If you have access to the first application's source code, it's a better idea to create a modified version that acts like a "script". I sometimes code in a "Batch Mode" setting that reads a value from an INI file to determine whether the app should install menu commands or not. Hope this helps Spencer ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Simon Allen Sent: Friday, March 17, 2006 4:58 AM To: [email protected] Subject: [MI-L] Run Application Hi I have a script which issues two Run Application commands. How can I ensure that the first application has finished running before issuing the second command? Ta Simon Allen Senior GIS Officer [EMAIL PROTECTED] South Gloucestershire Council 01454 863655 (direct) 01454 863855 (fax) http://www.southglos.gov.uk <http://www.southglos.gov.uk/> ********************************************************************** This email and any files transmitted with it from South Gloucestershire Council are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the South Gloucestershire Council Postmaster at the address below. This footnote also confirms that this email message has been swept for the presence of computer viruses. [EMAIL PROTECTED] ********************************************************************** _______________________________________________ MapInfo-L mailing list [email protected] http://www.directionsmag.com/mailman/listinfo/mapinfo-l
