<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 14px;" lang="x-unicode">Hi Dieter
<br>
<br>
the corresponding module in A2 looks like the following (below my
signature). It should be widely applicable to ETHOberon for
Windows because lot of Kernel32 is shared.
<br>
<br>
Aside: Command.Context is the current's thread context. You don't
have this in Oberon -- that should be the greatest difference. [In
the current version of A2, the command context is stored
Thread-locally and does not have to be explicitly coded, cf.
module In or Out in the current version of A2].
<br>
<br>
Rgds
<br>
Felix
<br>
<br>
<br>
<br>
MODULE WinApplications;Â (* ll, fof : call windows applications
from within WinAos *)
<br>
                     (*ll, add statements for waiting
process terminate in procedure Callprocess, 23.11.2007*)
<br>
                     (*ll, add return result of CallProcess
Procedure. IF resturn result = 0 THEN execution success END,
28.11.2007*)
<br>
<br>
IMPORT Kernel32, KernelLog, Commands, Strings, SYSTEM, Options;
<br>
<br>
   PROCEDURE CallProcess( par: ARRAY OF CHAR; visible: BOOLEAN ):
LONGINT;
<br>
   VAR bool: LONGINT; start: Kernel32.StartupInfo; pi:
Kernel32.ProcessInformation;Â result: LONGINT;
<br>
   BEGIN
<br>
      result := -1;
<br>
      start.cb := SIZEOF( Kernel32.StartupInfo );
<br>
      start.dwFlags := {Kernel32.StartFUseShowWindow};
<br>
      IF visible THEN start.wShowWindow := 1; ELSE
start.wShowWindow := 0; END;
<br>
<br>
      KernelLog.String( "Calling Windows Application: " );
KernelLog.String( par );Â KernelLog.Ln;
<br>
<br>
      bool := Kernel32.CreateProcess( NIL , par, NIL , NIL ,
Kernel32.False, 0, NIL , NIL , start, pi );
<br>
      result := Kernel32.WaitForSingleObject(pi.hProcess,
Kernel32.Infinite);
<br>
      bool := Kernel32. GetExitCodeProcess(pi.hProcess, result);
<br>
<br>
      RETURN result
<br>
   END CallProcess;
<br>
<br>
   PROCEDURE Call*( CONST proc, par: ARRAY OF CHAR): LONGINT;
<br>
   VAR call: ARRAY 1024 OF CHAR;
<br>
   BEGIN
<br>
      call := '"'; Strings.Append (call, proc); Strings.Append
(call, '" '); Strings.Append (call, par);
<br>
      RETURN CallProcess (call, TRUE);
<br>
   END Call;
<br>
<br>
   PROCEDURE Run*(context : Commands.Context);
<br>
   VAR options: Options.Options; visible: BOOLEAN; cmdpar: ARRAY
256 OF CHAR;Â res: LONGINT;
<br>
   BEGIN
<br>
      NEW (options);
<br>
      options.Add("h", "hide", Options.Flag);
<br>
      IF options.Parse(context.arg,context.error) THEN
<br>
         visible := ~options.GetFlag ("h");
<br>
      ELSE
<br>
         visible := TRUE;
<br>
      END;
<br>
      context.arg.Ln (cmdpar);
<br>
      res := CallProcess (cmdpar, visible);
<br>
      IF res = 0 THEN KernelLog.String( "should have worked
fine .... " );Â Â KernelLog.Ln;
<br>
      ELSE KernelLog.String( "ERROR: " ); res:=
Kernel32.GetLastError();Â KernelLog.Int(res, 1 );Â KernelLog.Ln;
<br>
      END;
<br>
      context.result := res;
<br>
   END Run;
<br>
<br>
END WinApplications.
<br>
<br>
SystemTools.Free WinApplications ~
<br>
System.Free WinApplications ~
<br>
<br>
~
<br>
WinApplications.Run avrdude -help ~
<br>
<br>
Aos.Call WinApplications.Run avrdude -p m128 -c avrisp -P com1 -e
~
<br>
Aos.Call WinApplications.Run Notepad Test.bat ~
<br>
Aos.Call WinApplications.Run Test.bat ~
<br>
~
<br>
<br>
EditTools.OpenAscii Test.Bat ~
<br>
<br>
<br>
<br>
<br>
<br>
<blockquote type="cite" style="color: #000000;">Short question:
<br>
<br>
has anybody got an idea, how I could accomplish this?
<br>
<br>
Thanks and regards,
<br>
Dieter
<br>
<br>
</blockquote>
<br>
</div>
</body>
</html>