Ignore:
Timestamp:
Jun 26, 2023, 12:08:45 PM (17 months ago)
Author:
chronos
Message:
  • Added: Var function parameters support.
  • Added: Read and ReadLn procedures support.
  • Added: Interpreter now prints into console form.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/xpascal/Forms/FormMain.pas

    r229 r230  
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus,
    77  ActnList, ExtCtrls, SynHighlighterPas, SynEdit, Source, Optimizer,
    8   Generator, FormSource, FormMessages, FormOutput, FormEx;
     8  Generator, FormSource, FormMessages, FormOutput, FormConsole, FormEx;
    99
    1010type
     
    1414  TFormMain = class(TFormEx)
    1515    ACompile: TAction;
     16    AConsole: TAction;
    1617    ATest: TAction;
    1718    AGenerateXml: TAction;
     
    4041    Splitter1: TSplitter;
    4142    procedure ACompileExecute(Sender: TObject);
     43    procedure AConsoleExecute(Sender: TObject);
    4244    procedure AExitExecute(Sender: TObject);
    4345    procedure AGenerateCSharpExecute(Sender: TObject);
     
    5860    FormMessages: TFormMessages;
    5961    FormOutput: TFormOutput;
     62    FormConsole: TFormConsole;
    6063    procedure Generate(GeneratorClass: TGeneratorClass);
    6164    procedure ExecutorOutput(Text: string);
     65    function ExecutorInput: string;
    6266    procedure InterpreterError(Pos: TPoint; Text: string);
    6367    procedure UpdateInterface;
     
    8387  if not Initialized then begin
    8488    Initialized := True;
    85     FormSource.SynEditSource.Lines.LoadFromFile('Test.pas');
     89    FormSource.SynEditSource.Lines.LoadFromFile('Examples' + DirectorySeparator +
     90      'Example.pas');
    8691    ARun.Execute;
    8792  end;
     
    9499  if Assigned(FormMessages) then FreeAndNil(FormMessages);
    95100  if Assigned(FormOutput) then FreeAndNil(FormOutput);
     101  if Assigned(FormConsole) then FreeAndNil(FormConsole);
    96102end;
    97103
     
    107113  FormOutput.Show;
    108114  DockForm(FormOutput, PanelOutput);
     115  FormConsole := TFormConsole.Create(nil);
     116  FormConsole.Show;
     117  DockForm(FormConsole, PanelOutput);
    109118  UpdateInterface;
    110119end;
     
    121130    FormOutput.SetText(Generator.Output);
    122131    TargetFileName := 'Generated' + DirectorySeparator +
    123       Generator.Name + DirectorySeparator + 'Test' + Generator.FileExt;
     132      Generator.Name + DirectorySeparator + 'Example' + Generator.FileExt;
    124133    ForceDirectories(ExtractFileDir(TargetFileName));
    125134    FormOutput.SynEditOutput.Lines.SaveToFile(TargetFileName);
     
    152161end;
    153162
     163procedure TFormMain.AConsoleExecute(Sender: TObject);
     164begin
     165
     166end;
     167
    154168procedure TFormMain.AGenerateCSharpExecute(Sender: TObject);
    155169begin
     
    161175    Generate(TGeneratorCSharp);
    162176  end;
     177  DockForm(FormOutput, PanelOutput);
    163178end;
    164179
     
    171186    Generate(TGeneratorPascal);
    172187  end;
     188  DockForm(FormOutput, PanelOutput);
    173189end;
    174190
     
    182198    Generate(TGeneratorPhp);
    183199  end;
     200  DockForm(FormOutput, PanelOutput);
    184201end;
    185202
     
    192209    Generate(TGeneratorXml);
    193210  end;
     211  DockForm(FormOutput, PanelOutput);
    194212end;
    195213
     
    236254    Executor.Prog := Prog;
    237255    Executor.OnOutput := ExecutorOutput;
     256    Executor.OnInput := ExecutorInput;
    238257    Executor.Run;
    239258    Executor.Free;
    240259  end;
     260  DockForm(FormConsole, PanelOutput);
     261  FormConsole.Memo1.SetFocus;
    241262end;
    242263
     
    259280procedure TFormMain.ExecutorOutput(Text: string);
    260281begin
    261   FormOutput.SynEditOutput.Text := FormOutput.SynEditOutput.Text + Text;
     282  FormConsole.Memo1.Text := FormConsole.Memo1.Text + Text;
     283end;
     284
     285function TFormMain.ExecutorInput: string;
     286begin
     287  Result := FormConsole.GetInputString;
    262288end;
    263289
Note: See TracChangeset for help on using the changeset viewer.