Darwinbots Forum

Code center => Darwinbots Program Source Code => Topic started by: Botsareus on January 31, 2014, 05:59:27 PM

Title: Serios bug in vb6, or is it?
Post 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()
Code: [Select]
'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"

Code: [Select]
        MDIForm1.WindowState = 0
        DoEvents
        MDIForm1.Move 0, 0

The program will not exit no matter what I do.
Any ideas?
Title: Re: Serios bugo in vb6
Post by: Botsareus on January 31, 2014, 11:48:14 PM
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.
Title: Re: Serios bug in vb6, or is it?
Post by: Numsgil on February 01, 2014, 11:55:08 AM
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).
Title: Re: Serios bug in vb6, or is it?
Post by: Botsareus on February 02, 2014, 09:48:18 AM
Oh, ok. Thank you.
Title: Re: Serios bug in vb6, or is it?
Post by: Botsareus on February 02, 2014, 10:46:38 AM
Damn, still does not work.
I am using:
Code: [Select]

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?
Title: Re: Serios bug in vb6, or is it?
Post by: Botsareus on February 02, 2014, 11:48:40 AM
It was a complete pain, but I got a work around. I am telling restarter to kill the process by path.