Hello All,
Response for "MI Running DOS programs from
MapBasic"
You might want the snatch TreePAD, so you can keep
"snippets" like this is
an explorer style note pad. It has unlimited
size and drag/drop functionality.
The program is only 516k, no install, or other
pig-ware with a manual that is the startup example
Q: How can I execute a program and have MapBasic
wait for its completion?
A:..................
Have you UnChecked the "run in
background" property of the DOS app?
Right click on the FileName.EXE in
WinExploder
Select "Properties" from the bottom of
the popup menu
Select the "Misc" tab on the
right
Be sure "Background > Always Suspend"
is UNCHECKED
I have this same problem when spawning apps from my
applications [especially when customer installs app]
[ last one is DOS app reading a dump from the comm
port, putting it in a fixed length file so the main app can
pick it up and load it to a dBase file. Method
allows for capturing data even if program is not running-get it
later]
Having it checked will keep the app virtually
"asleep" in the background..................
Here's what I use...........
Also you can use WinAPI "FindWindow" to
check for the window name [ if the app will terminate itself on completion
]
code is included below...............
The window must be a "top level" window
[you launched app] and not a child window [map window]
To do a child is a bit more complex as you have to
loop thru all of M$ Wins to find the one you want
=================================
this example was pasted from tested MB4.1
code
using WinNT4W / sp4 and MI4.5
=================================
' FIRST PICK YOUR OS > Win9x/NT
'''FOR 32 BIT [ NT
]
' KEEP THIS NEXT LINE ON 1
LINE - don't split it
Declare Function FindWindow
Lib "user32" Alias "FindWindowA" (ByVal lpClassName As
String, ByVal lpWindowName As String) As Integer
'''FOR 16 BIT [ 9x ] ---- 9x still runs a lot of stuff under 16bit
' KEEP THIS NEXT LINE ON 1 LINE - don't split it
'Declare Function FindWindow Lib "user32" Alias "FindWindow" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer DIM ClassName as String
DIM Title as String
DIM AppRunning AS Integer
Declare sub Main
sub Main'''FOR 32 BIT [ NT ] this is what I'm running............and I started "command promt" manually
ClassName = "ConsoleWindowClass"
Title = "Command Prompt"
' NOTE: title has to be EXACTLY what is in the window title......if app is MyDosApp.exe then > "MyDosApp.exe" do 'prints until command prompt is terminted [stopped manually]
AppRunning = FindWindow(ClassName, Title)
print "DOS Window Handle Is = " + AppRunning
'''''......delete above line after debugging.............
loop while DosAppRunning > 0
''' --- continue you code
End Sub
====================================================================
Hope this helps......see my post also and check my
web site
