Jump to content

Kryvich

Members
  • Content Count

    402
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by Kryvich


  1. My projects is not so big as yours... OK I downloaded the nightly build of mORMot and tried to open several DPR in Delphi 10.3. In the TestSQL3 project, ErrorInsight showed 2 false-positive errors:

    • 'Synopse.inc' could not be found in the current project
    • 'SynDprUses.inc' could not be found in the current project

    TestSQL3.dpr in the mORMot\SQLite3 folder, and these INC files in mORMot folder.

    When I replaced {$I Synopse.inc} with {$I ..\Synopse.inc} and {$I SynDprUses.inc} with {$I ..\SynDprUses.inc} these errors are gone.

     

    What other errors in ErrorInsight have you encountered in projects with mORMot?


  2. We can always "fool" the compiler using pointers.

    procedure TestMyStep;
    var
      i: Integer;
    begin
      for i := 1 to 10 {step 2} do begin
        Writeln(i);
        PInteger(@i)^ := PInteger(@i)^ + 2-1;
      end;
      Readln;
    end;

    But we must understand what we are doing. The compiler checks the counter for an exact match with the final value. If in your (or my) example the step size would be 3, we would get an infinite loop.


  3. Quote

    This is compatible in terms of parameters with the Windows API of the same name, so an existing call to the API in one of your components gets redirected to the method, which in turn calls GetSystemMetricsForWindow passing the control's parent handle as parameter.

    If I understand properly, to get a form's handle that a component belongs to, you need to use its Owner property, not the Parent property.

     

    type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if Button1.Parent.Handle = Panel1.Handle then
        ShowMessage('My parent is Panel1');
      if (Button1.Owner as TWinControl).Handle = Form1.Handle then
        ShowMessage('My owner is Form1');
    end;

    Good addition BTW!


  4. I just downloaded the library from GitHub: https://github.com/graphics32/graphics32.

    They added some fixes and changes compared to the official version on SourceForge.

    On Delphi 10.2.3 everything was compiled without errors (Win32):

    • ...\Source\Packages\XE8\GR32.groupproj  -- Build all, install GR32_D package.
    • Add ...\Source to your library path (Tools | Options | Environment options | Delphi options | Library | Platform 32-bit Windows | Library path.
    • ...\Examples\Examples.groupproj  - Build all.

    There was the unit FastMM4 in one of the examples - just delete it from the uses clause.


  5. @uligerhardt It seems that it does not. Neither for records, nor for arrays.

    function GetRec: TRec;
    begin
      // Forgot to assign Result...
    end;
    
    function GetArr: TArray<Integer>;
    begin
      // Forgot to assign Result...
    end;
    
    var
      rec: TRec;
      arr: TArray<Integer>;
    begin
      rec.Data := 255;
      rec := GetRec;
      Writeln('rec.Data = ', rec.Data); // = 0
    
      SetLength(arr, 1000);
      arr := GetArr;
      Writeln('Length of arr = ', Length(arr)); // = 0
      Readln;
    end.

     


  6. Well I found the bindings: 

    Quote

    Finding the Next and Previous Changes

    As you edit code, you can use keystrokes to quickly navigate to the Next and the Previous changes that you have made. The keyboard shortcuts are:

    • Ctrl+Shift+F7 -- moves to the previous line modified since the file was opened (green marking in the gutter).
    • Ctrl+Shift+F8 -- moves to the next line modified since the file was opened (green marking in the gutter).
    • Alt+Shift+F7 -- moves to the previous line modified since the last save (yellow marking in the gutter).
    • Alt+Shift+F8 -- moves to the next line modified since the last save (yellow marking in the gutter).

    http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Code_Editor

    • Like 1
    • Thanks 1

  7. Still, it is not clear why the compiler did not issue a warning about an unassigned Result. I minified the code to make it clearer.

    program TestUnassignedResult;
    {$APPTYPE CONSOLE}
    type
      TRec = record
        Data: Byte;
        function NS: TRec;
      end;
    
    function TRec.NS: TRec;
    begin
      Writeln('I''m in NS');
      // W1035 Return value of function 'NS' might be undefined <-- not showed!!!
    end;
    
    begin
      //..
    end.

     

×