Linux users,
Can you guys test to see if this BlitzMax code launches and handles an external program correctly?
a) Does a launched program run correctly?
Example: Try launching the BlitzMax IDE and monitoring the status bar of the laucher program.
b) Does the lauched program close immediately afterwards by itself?
c) can you terminate the launched program from the launchers GUI [Terminate application] button?
Can you guys test to see if this BlitzMax code launches and handles an external program correctly?
a) Does a launched program run correctly?
Example: Try launching the BlitzMax IDE and monitoring the status bar of the laucher program.
b) Does the lauched program close immediately afterwards by itself?
c) can you terminate the launched program from the launchers GUI [Terminate application] button?
' Application Launcher ' Simons library Import PUB.FreeProcess AppTitle$="Max App Launcher" ' simple gui Global win:TGadget=CreateWindow(AppTitle$,60,60,180,160,0,9) Local but1:TGadget=CreateButton("Run applicaton",24,24,114,24,win,1) Local but2:TGadget=CreateButton("Terminate application",24,56,114,24,win,1) ' variable to handle the launched application Local myproc:TProcess ' timer for updating the statusbar Local t:TTimer=CreateTimer(1) ' cross-platform executable extension filter ?Win32 Const ext$="Executable:exe" ?Linux Const ext$="" ?Mac Const ext$="Application:app" ? ' ===================================== ' main loop Repeat ' DebugLog CurrentEvent.ToString() Select WaitEvent() Case EVENT_GADGETACTION Select EventSource() Case but1 If AppRunning(myproc) Notify StripDir$(myproc.name$)+" still running!" Else f$=RequestFile$("Choose Executable",ext$) myproc=RunApp(f$) EndIf Case but2 If AppRunning(myproc) myproc.Terminate Else Notify "No program to terminate" EndIf End Select Case EVENT_TIMERTICK UpdateStatusBar myproc Case EVENT_WINDOWCLOSE Exit End Select Forever End ' ===================================== ' launch an application Function RunApp:TProcess(app$) If app$="" Return Null Local proc:TProcess=TProcess.Create(app$,0) If Not Proc Notify "Failed to launch "+app$ Return proc End Function ' return true if app still running Function AppRunning(p:TProcess) If p<>Null If p.Status() Return True EndIf End Function ' update the status bar to reflect 'app running' status Function UpdateStatusBar(p:TProcess) If p=Null SetStatusText win,"App not running" Return EndIf If p.Status() SetStatusText win,StripDir$(p.name$)+" running" Else SetStatusText win,"App terminated" EndIf End Function