Darwinbots Forum
Code center => Darwinbots Program Source Code => Topic started by: Botsareus on January 31, 2014, 05:59:27 PM
-
I can not get the program to exit on "end" statement.
for example:
The following is at the bottom of Public Sub UpdateSim()
'R E S T A R T N E X T
'Botsareus 1/31/2014 seeding
If x_restartmode = 1 Then
If SimOpts.TotRunCycle = 200 Then
FileCopy MDIForm1.MainDir & "\league\test.txt", NamefileRecursive(MDIForm1.MainDir & "\league\seeded\" & totnvegsDisplayed & ".txt")
Open App.path & "\restartmode.gset" For Output As #1
Write #1, x_restartmode
Write #1, x_filenumber
Close #1
x_end = True
shell App.path & "\Restarter.exe " & App.path & "\" & App.EXEName
MDIForm1.WindowState = 0
DoEvents
MDIForm1.Move 0, 0
End If
End If
If I replace the following with "end"
MDIForm1.WindowState = 0
DoEvents
MDIForm1.Move 0, 0
The program will not exit no matter what I do.
Any ideas?
-
I was thinking it is because I am calling "shell" right before "end" but maybe it is because the code was nesting from the mdiform startup subroutine.
I am going to try to move the "end" code to the seconds timer tomorrow and see if that fixes it. cross-fingers.
-
I believe the program will block until the shell command finishes. What you want is probably something like exec from linux. On windows, your best bet is probably to do a WinAPI call. eg: create process (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx).
-
Oh, ok. Thank you.
-
Damn, still does not work.
I am using:
Public Sub SuperShell(pname As String)
Dim pInfo As PROCESS_INFORMATION
Dim sInfo As STARTUPINFO
Dim sNull As String
Dim lSuccess As Long
Dim lRetValue As Long
sInfo.cb = Len(sInfo)
lSuccess = CreateProcess(sNull, _
pname, _
ByVal 0&, _
ByVal 0&, _
1&, _
NORMAL_PRIORITY_CLASS, _
ByVal 0&, _
sNull, _
sInfo, _
pInfo)
End Sub
Do I need to declare anything differently?
-
It was a complete pain, but I got a work around. I am telling restarter to kill the process by path.