Changeset 151


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

Legend:

Unmodified
Added
Removed
  • trunk/BFCodeTools.pas

    r145 r151  
    2020  Multiplier: Integer;
    2121  Remainder: Integer;
    22 const
    23   Overhead = 7;
    2422begin
    2523  Result := '';
  • trunk/LazFuck.lpi

    r150 r151  
    9797      </Item4>
    9898    </RequiredPackages>
    99     <Units Count="30">
     99    <Units Count="31">
    100100      <Unit0>
    101101        <Filename Value="LazFuck.lpr"/>
     
    260260        <IsPartOfProject Value="True"/>
    261261      </Unit29>
     262      <Unit30>
     263        <Filename Value="Forms\FormConsole.pas"/>
     264        <IsPartOfProject Value="True"/>
     265        <ComponentName Value="FormConsole"/>
     266        <ResourceBaseClass Value="Form"/>
     267      </Unit30>
    262268    </Units>
    263269  </ProjectOptions>
  • trunk/LazFuck.lpr

    r150 r151  
    1010  Interfaces, // this includes the LCL widgetset
    1111  Forms, Target, FormCPU, FormMain, FormOutput, FormInput, FormMemory,
    12   FormMessages, FormSourceCode, FormTargetCode, Core, Common,
     12  FormMessages, FormSourceCode, FormTargetCode, FormConsole, Core, Common,
    1313  SysUtils, BFCodeTools, TargetRust;
    1414
  • 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.