My original problem was automated conversion of many files from TAB to SHP as part of a multi-stage conversion (The SHP's were then further converted by a closed app that did not recognize TABs)
Several suggestions were: 1) use a command line with the /wait parameter (Bill Thoen) 2) monitor a "sentinel" file - in the last line of the batch file delete the file then while fileexists(sentinel file) do Application.Processmessages (Trey Pattillo) In my experience these are not a whole answer. My program builds a batch file that looks like this (ignore the line wrap around...): Start "TS2" /wait /b "C:\Program Files\MapInfo\Professional\UT\IMUT.EXE" usa7200.XXX Start "TS2" /wait /b "C:\Program Files\MapInfo\Professional\UT\IMUT.EXE" usa720102.XXX Start "TS2" /wait /b "C:\Program Files\MapInfo\Professional\UT\IMUT.EXE" usa7203.XXX ...followed by many more lines with only the .XXX file changed. XXX is a file build by calling IMUT with generate, etc. (My data is not X rated, I just found it important to choose an extension that was not associated with some other program.) When this is run, task manager shows as many as 15 instances of IMUT.EXE running - clearly line two is not waiting for line one to finish, but on the other hand, since these are separate processes they don't interfere with each other, which is the first thing I cared about. They finish at different times, and when each finishes apparently depends on how much processing it has to do - not in what order it was started. Problem #2 concerns checking for the presence of a dummy file created at the beginning of the batch and delete at the end. Say you have a three stage batch, first you create a dummy file, then you start a process such as IMUT which creates an output file, finally, you delete the dummy file. Problem is, as above, step three does not wait for step two. While IMUT may well have _created_ it's output file before the sentinel file is deleted, it may continue to write to that output file for a long time (60 seconds, on my machine, depending on amount of data). I cannot actually access the output file for further processing until IMUT is finished writing to it, even though my dummy file has long since disappeared. Checking the access properties of the output file would probably work, but that's not the same thing. What my program is doing now, and what works, is creating a batch file as described above to convert each of a group of files using IMUT. After it launches the batch file it waits a short time (1 second) to make certain the process is running and can be detected. It then enumerate the windows processes looking for IMUT.EXE, while doing Application.ProcessMessges. If IMUT.EXE is not found - some number of times in succession (I finally used 30) - it considers that IMUT has finished and the the next stage of processing may take place. I found that it really was necessary both to wait before looking for process IMUT and also to check for its non-presence a large number of times in a row. Since Windows takes a 'snapshot' of the running processes which we are starting successively, it's possible to catch it at a point where a given process apparently falls through the cracks. I figure the 1 second wait and the couple of milliseconds of 30 iterations of process checking are acceptable in the circumstanes. Having said all that, I don't know why the routines that use CreateProcess followed by WaitForsingleObject don't seem to work. I'd be interested in seeing Bo Thomsen's DLL if it includes source, to see what the differences are between that implementation and the ExecAndWait functions I've seen that use CreateProcess and WaitForsingleObject. My program (in Delphi, with source) will be available to whoever is interested, as soon as I've cleaned it up a bit. (And edited it to a version that does not include all the processing following the Tab to Shape conversion, which no one here is likely to care about....) Mickey -- Mickey Feldman [EMAIL PROTECTED] 1) Please reply to List/Newsgroup, not directly unless specifically requested. If it's a useful answer other will be interested too. 2) I'm on digest on all lists - don't take a slow reponse personally. --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 11337
