Changeset 230 for branches/xpascal/Forms


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.
Location:
branches/xpascal/Forms
Files:
3 added
4 edited

Legend:

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

    r229 r230  
    11object FormMain: TFormMain
    2   Left = 482
     2  Left = 534
    33  Height = 993
    4   Top = 205
     4  Top = 223
    55  Width = 1491
    66  Caption = 'Interpreter'
     
    125125      ShortCut = 122
    126126    end
     127    object AConsole: TAction
     128      Caption = 'Console'
     129      OnExecute = AConsoleExecute
     130    end
    127131  end
    128132end
  • branches/xpascal/Forms/FormMain.lrj

    r227 r230  
    1212{"hash":315140,"name":"tformmain.aexit.caption","sourcebytes":[69,120,105,116],"value":"Exit"},
    1313{"hash":209392028,"name":"tformmain.ageneratexml.caption","sourcebytes":[71,101,110,101,114,97,116,101,32,88,77,76],"value":"Generate XML"},
    14 {"hash":371876,"name":"tformmain.atest.caption","sourcebytes":[84,101,115,116],"value":"Test"}
     14{"hash":371876,"name":"tformmain.atest.caption","sourcebytes":[84,101,115,116],"value":"Test"},
     15{"hash":174433893,"name":"tformmain.aconsole.caption","sourcebytes":[67,111,110,115,111,108,101],"value":"Console"}
    1516]}
  • 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
  • branches/xpascal/Forms/FormOutput.lfm

    r227 r230  
    11object FormOutput: TFormOutput
    2   Left = 607
     2  Left = 563
    33  Height = 544
    4   Top = 252
     4  Top = 339
    55  Width = 932
    66  Caption = 'Output'
Note: See TracChangeset for help on using the changeset viewer.