Changeset 151 for trunk/Target.pas


Ignore:
Timestamp:
Jun 5, 2024, 10:24:47 PM (5 months ago)
Author:
chronos
Message:
  • Added: Execute compiled program with targets without executor inside console window to see its output.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Target.pas

    r145 r151  
    154154  end;
    155155
    156 
    157156resourcestring
    158157  SCompilerNotFound = 'Compiler "%s" not found';
     
    182181
    183182implementation
     183
     184uses
     185  FormConsole;
    184186
    185187procedure UpdateTranslation;
     
    531533procedure TTarget.RunFromFile;
    532534var
    533   Process: TProcess;
    534535  CompiledFile: string;
    535536  RunFile: string;
    536 begin
    537   if ExecutorPath = '' then Exit;
    538 
     537  FormConsole: TFormConsole;
     538begin
    539539  CompiledFile := ExtractFilePath(ProjectFileName) +
    540540    CompiledDir + DirectorySeparator + Name + DirectorySeparator +
     
    543543    CompiledDir + DirectorySeparator + Name + DirectorySeparator +
    544544    ExtractFileNameOnly(ProjectFileName) + RunExtension;
    545   if not FileExists(ExecutorPath) then
    546     raise Exception.Create(Format(SExecutorNotFound, [ExecutorPath]));
    547545  if FileExists(CompiledFile) then
    548546  try
    549     Process := TProcess.Create(nil);
     547    FormConsole := TFormConsole.Create(nil);
    550548    if ExecutorPath <> '' then begin
    551       Process.Executable := LongFileName(ExecutorPath);
    552       Process.Parameters.Add(LongFileName(RunFile));
    553     end else Process.Executable := LongFileName(RunFile);
    554     Process.ShowWindow := swoShow;
    555     Process.Options := [poWaitOnExit, poNewConsole];
    556     Process.Execute;
     549      if not FileExists(ExecutorPath) then
     550        raise Exception.Create(Format(SExecutorNotFound, [ExecutorPath]));
     551      FormConsole.Executable := LongFileName(ExecutorPath);
     552      FormConsole.Parameters.Add(LongFileName(RunFile));
     553    end else
     554      FormConsole.Executable := LongFileName(RunFile);
     555    FormConsole.ShowModal;
    557556  finally
    558     Process.Free;
    559   end else raise Exception.Create(Format(SCompiledFileNotFound, [CompiledFile]));
     557    FormConsole.Free;
     558  end
     559  else raise Exception.Create(Format(SCompiledFileNotFound, [CompiledFile]));
    560560end;
    561561
Note: See TracChangeset for help on using the changeset viewer.