by
MITCHELL1 >> Mon, 22 Jul 2002 2:11:36 GMT
An alternative you could try, if you have JSM Start (CardSchema) is to use the external method call 'emCreateProcess' in karma.dll. If you run this with modal=true then you can also capture the standard out during the process execution. The method signature is
emCreateProcess( obj: Object;
cmdLine: String;
modal: Boolean;
notifyStdOut: Boolean;
childStdInText: String;
tag : Integer;
exitCode: Integer output): Integer is "emCreateProcess" in "karma";
1. Your karma.dll needs to be version 2.6.2.12 or later.
2. The 'tag' that is part of the emCreateProcess method signature is returned as part of the userNotification . The eventType that is caused by the dll is hard coded and has the value 9950. In the attached method file, you'll see that I have a global constant Process_Std_Out_Event. This has value 9950 and is what the application that is to receive the std out must subscribe to.
3. The notification itself (userInfo) is a Binary structure : the first four bytes are an Integer representing the eventTag that you supplied in the 'tag' parameter of the emCreateProcess call. This is optional and can be zero. The remaining bytes of the userInfo[5:end] are a string containing the std out.
4. Exit code only has a meaning when modal=true.
You need two apps to make this work : one is the 'ProcessLogger', which receives std out notifications from karma.dll, and the other is your main-line process which executes the emCreateProcess and normally blocks until the process ends.
App1 should
vars
proc : Process;
yourObj : YourObject;begin
beginTransientTransaction;
create yourObj sharedTransient; // I use a shared transient here, but a persistent object could also be used
commitTransientTransaction;
proc := app.startApplicationWithParameter(<schema>,<App2>, yourObj);
result := app.emCreateProcess(yourObj, commandline, true, true, null, Process_Std_Out_Event, exitCode);
if exitCode <> 0 then ..... // error handling
App2 in its initialisation method should
initialiseApp2(yourObj : YourObject);
vars
result : Integer;
exitCode : Integer;begin
self.beginNotification(yourObj, Process_Std_Out_Event, 0, 0);
end;
And in the userNotification event (on self i.e. app, in this example) you receive the std out in the userInfo part of the notification. Note that this comes in dribs and drabs and you'll need to search for CrLf if you want to get each line nicely formatted.
Hope this helps.
--
Richard W Mitchell
Senior Software Engineer
Systems Management Development Centre
Jade Software Corporation Ltd
mailto:
rmitchell@jade.co.nz