B4J Question Run a .exe File with jShell

Discussion in 'B4J Questions' started by Cal4th, Jan 3, 2018.

  1. Cal4th

    Cal4th Member

    I am trying to run a .exe application with a button. The app is located in the Object Folder of the B4J file. When I click the button the app doesn't start and it doesn't appear any error in the logs it just doesn't start. the code im using is below.
    Code:
    Dim xfoil As Shell
        
    Dim params As List: params.Initialize
        
    Dim FileRun As String
       
        params.Add(
    File.DirApp)
        FileRun= 
    File.Combine(File.DirApp , "xfoil.exe")
        
    Log(FileRun)

        
    'xfoil.Initialize("xfoil",FileRun, Null)
        xfoil.Initialize("xfoil",FileRun, params)
        xfoil.WorkingDirectory = 
    File.DirApp
        xfoil.Run(-
    1)
    In the Log it appears correctly the FileRun
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Where is the ProcessCompleted event?
     
  3. Cal4th

    Cal4th Member

    I couldn't understand how did it work and how to define it. I did fined how to define it in the explanation of jShell, and when I use the example given, it does the same.
    this is the code with the ProcessCompleted Event:
    Code:
    Sub btnRun_MouseClicked (EventData As MouseEvent)
        
        
    Dim xfoil As Shell
        
    Dim params As List: params.Initialize
        
    Dim FileRun As String
        
        params.Add(
    File.DirApp)
        FileRun= 
    File.Combine(File.DirApp , "xfoil.exe")
        
    Log(FileRun)

        
    'xfoil.Initialize("xfoil",FileRun, Null)
        xfoil.Initialize("xfoil",FileRun, params)
        xfoil.WorkingDirectory = 
    File.DirApp
        xfoil.Run(-
    1)

    End Sub

    Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
        
    If Success And ExitCode = 0 Then
            
    Log("Success")
            
    Log(StdOut)
        
    Else
            
    Log("Error: " & StdErr)
        
    End If
        
    ExitApplication
    End Sub
    Hope it is useful to help me solve the question.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You set the event name to xfoil. The event sub should be xfoil_ProcessCompleted.
     
  5. Cal4th

    Cal4th Member

    I changed it and it gives me other error.

    Code:
    Sub btnRun_MouseClicked (EventData As MouseEvent)
        
        
    Dim xfoil As Shell
        
    Dim params As List
        
    Dim FileRun As String
        params.Initialize
        params.Add(
    File.DirApp)
        FileRun= 
    File.Combine(File.DirApp , "xfoil.exe")
        
    Log(FileRun)

        
    'xfoil.Initialize("xfoil",FileRun, Null)
        xfoil.Initialize("xfoil",FileRun, params)
        xfoil.WorkingDirectory = 
    File.DirApp
        xfoil.Run(-
    1)

    End Sub

     
    Private Sub xfoil_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
        
    If Success And ExitCode = 0 Then
            
    Log("Success")
            
    Log(StdOut)
        
    Else
            
    Log("Error: " & StdErr)
        
    End If
        
    ExitApplication
    End Sub
    Error: At line 135 of file ../src/userio.f (unit = 5, file = 'stdin')
    Fortran runtime error: End of file
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    This is the error printed from the executable.
     
  7. Cal4th

    Cal4th Member

    Perfect, Thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice