Code: Alles auswählen
tterminal1.execprog(
'avr-gcc -mmcu=atmega32 -mcall-prologues -Wall -O0 -DF_CPU=16000000UL '+
'-c main.c -o main.o');
Code: Alles auswählen
tterminal1.execprog(
'avr-gcc -mmcu=atmega32 -mcall-prologues -Wall -O0 -DF_CPU=16000000UL '+
'-c main.c -o main.o');
Code: Alles auswählen
Function ExecuteCommand(App, Param, logname: String): String;
Var
AProcess: TProcess;
sl: TStringList;
Begin
// Entnommen aus : http://wiki.lazarus.freepascal.org/Executing_External_Programs/de#Ein_verbessertes_Beispiel" onclick="window.open(this.href);return false;
AProcess := TProcess.Create(Nil);
AProcess.CommandLine := 'bash -c "' + app + ' ' + param + ' >' + logname + ' 2>&1"';
AProcess.Options := AProcess.Options + [poNoConsole, poWaitOnExit];
AProcess.Execute;
AProcess.Free;
// Auslesen der Logfile
sl := TStringList.create;
sl.LoadFromFile(logname);
result := sl.text;
sl.free;
End;
.. hab's mal korrigiert; das war nur schnell zusammenkopiert und mit ein wenig VBA-Syntax gemischtcorpsman hat geschrieben:Ohne Deine Syntaxfehler
Code: Alles auswählen
....
var Buffer: string;
BytesAvailable: DWord;
BytesRead:LongInt;
begin
...
AProcess.Execute;
BytesAvailable := Process.Output.NumBytesAvailable;
BytesRead := 0;
while BytesAvailable>0 do begin
SetLength(Buffer, BytesAvailable);
BytesRead := AProcess.OutPut.Read(Buffer[1], BytesAvailable);
Memo1.Text := Memo1.Text + UTF8Encode(Buffer);
//früher anstatt UTF8... das verwendet copy(Buffer,1, BytesRead);
//aber dann hat Memo1 nichts gezeigt
BytesAvailable := AProcess.Output.NumBytesAvailable;
end;
//memo scrollen
if BytesRead>0 then begin Application.ProcessMessages; Memo1.SelStart := Length(Memo1.Text); end;
...
end;