AbtProgramStarter synchronous process

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

AbtProgramStarter synchronous process

Postby skock » Fri May 07, 2010 6:25 am

Hi,

I need to call an external program from a VAST 7.0.2 application and wait until it is terminated, unfortunately AbtProgramStarter works asynchronously. In an old redbook
http://www.redbooks.ibm.com/redbooks/pdfs/sg242219.pdf
there is a recommendation of subclassing AbtProgramStarter, but no details are presented.

Also, I played around a bit with
OSCall>>#createProcess:lpszCommandLine:lpsaProcess:lpsaThread:fInheritHandles:fdwCreate:lpvEnvironment:lpszCurDir:lpsiStartInfo:lppiProcInfo:
, but I didn't get a clue

Any advice or suggestion will be appreciated,

thanks in advance, Stefan
skock
 
Posts: 2
Joined: Fri May 07, 2010 5:35 am

Re: AbtProgramStarter synchronous process

Postby marten » Fri May 07, 2010 7:18 am

One way could be to download the application MSKPlatformExtension from vastgoodies.com and then you may look at MSKProgramStarter and there is a method startProgramAndWaitForEnd (working only under Windows). The method simply polls the status of the running process.
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: AbtProgramStarter synchronous process

Postby marten » Fri May 07, 2010 7:57 am

marten wrote:One way could be to download the application MSKPlatformExtension from vastgoodies.com and then you may look at MSKProgramStarter and there is a method startProgramAndWaitForEnd (working only under Windows). The method simply polls the status of the running process.


As an alternative to "startProgramAndWaitForEnd" you may use:

Code: Select all
startProgramAndWaitForEnd2
   "<Integer | AbtError> I start a program and wait for the end of that process and return either an integer, holding   the returnc code, or myself
   
  | aStarter |

  aStarter := MSKProgramStarter new.
  (aStarter
    programPath: 'E:\programmierung\es2005-1\ExeProjects\WaitForPrognoseCrawlCreator\WaitForPrognoseCrawlCreator\bin\Debug\WaitForPrognoseCrawlCreator.exe' ;
    parameters: '' ;
    startProgramAndWaitForEnd) = 1.
  (aStarter
    programPath: 'e:\programme\tools\basename' ;
    parameters: '--help' ;
    startProgramAndWaitForEnd2) = 0.

  "
  | returnInformation bool lpExitCode rc shellExecuteInfo |

  returnInformation := self primitiveStartProgram.
  (returnInformation at: 5) notNil
     ifTrue:[ rc := AbtError errorText: (returnInformation at: 5)]
     ifFalse:[
       shellExecuteInfo := returnInformation at: 1.
       lpExitCode := OSInt32 calloc: 1.
       rc := shellExecuteInfo hProcess waitForSingleObject: PlatformConstants::Infinite.   
       (shellExecuteInfo hProcess getExitCodeProcess: lpExitCode)
          ifTrue:[ rc := lpExitCode int32At: 0 ]
          ifFalse:[
            | errorText |
            errorText := MSKOperatingServices GetLastErrorMessageOrNil.
            rc := AbtError errorText: errorText.               
          ].
        lpExitCode free.         
      1 to: 4 do: [ :eachIndex |
        (returnInformation at: eachIndex) notNil ifTrue:[  (returnInformation at: eachIndex)  free ]
      ].
      ^rc   
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: AbtProgramStarter synchronous process

Postby marten » Fri May 07, 2010 10:19 am

I added a similar method to MSKPlatformExtension and update the versin of MSKPlatformExtension to 1.12 ...
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: AbtProgramStarter synchronous process

Postby skock » Sun May 09, 2010 11:36 pm

Hello Marten,

thank you very much, works great.

Stefan
skock
 
Posts: 2
Joined: Fri May 07, 2010 5:35 am


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest