Jump to content

Lars Fosdal

Administrators
  • Content Count

    3522
  • Joined

  • Last visited

  • Days Won

    116

Posts posted by Lars Fosdal


  1. 7 hours ago, Robert Gilland said:

    Can I passing an SQL (select Statement )into a REST Request to a Rest Server , and receive a result in a JSON Dataset?

    Can I pass an INSERT/UPDATE/DELETE Statement into a Rest Request?

    Short answer:

    Yes

     

    Long answer:

    Yes, but don't! It would put your SQL database at risk.

     

    Instead, build a proper REST API as

    - it hides the underlying database

    - it allows you to change the underlying database operations without changing the client

    A REST API done right is far more secure and robust.

    • Like 6

  2. If you currently are a Delphi/RAD Studio subscriber, you can request access to the beta if you didn't already get an invite.

    As per the link in the starting post of this thread:

    Quote

    If you are entitled to participate (current on subscription) and haven’t received the email invite, please check your spam folder first, and then reach out to your Embarcadero sales representative or reseller, to ask for a new invite.


    Closing this thread.


  3. I would decouple the action by having a handler.

     

    unit Druga;
    
    interface
     uses
      Dialogs;
    
    function Demo:boolean;
    
    type
      TOnShowMessage = reference to procedure;
    var
      OnShowMessage: TOnShowMessage;
    
    implementation
    // No circular ref here
    
    function demo: boolean;
    begin
      if Assigned(OnShowMessage)
      then OnShowMessage
      else raise Exception.Create('Someone forgot to set the OnShowMessage handler');
    end;
    
    initalization
      OnShowMessage := nil;
    end.

    In Prva, I'd connected the handler in f.x. FormCreate;

     

    procedure TForm1.FormCreate(sender: TObject);
    begin
      Druga.OnShowMessage(Self.MyShowMessage);
    end;
    
    procedure TForm1.MyShowMessage;
    begin
      ShowMessage(Form1.Edit1.Text);
    end;

    This avoids the circular unit ref, and since you initialize the handler from the main form, it shouldn't matter if the bpl is dynamically loaded?

    If you want to, you can of course also add parameters to the handler to display a text generated in unit Druga or have multiple handlers for different uses.

     

     


  4. You can also define symbols in an environment variable, but then they apply to ALL projects you compile.
    dcc_define=Test;MagicSymbol;SomeOtherDefine
    dcc_define being the magic environment variable name which defines the symbols.

    Example:

    image.thumb.png.9240a9e7d1aaf03fa2af26fd8126d933.png


    This one defines "foslar" - so that I can include code that I am working on but which doesn't compile in the project and commit/push to git without breaking the build server or messing up for other users.
     

    {$ifdef foslar}
    procedure DoSomething
    begi
      What was I thinking?
    {$endif}

     


  5. I have a 5K 40" Lenovo, that can be split into two "virtual" displays.  I can set up different resolutions and scalings on those when I need to test HighDPI. 
    Generally speaking, the test results are so disheartening that I still stick with 100% scaling in the OS, and use BDS in DPI-Unaware mode.


  6. Generally speaking I prefer offloading background tasks to a threadpool in-queue. The threadpool messages the main thread when the work is done. The main thread then retrieves the response from the threadpool out-queue.(i.e. mailbox principle).

    If there are multiple parallell tasks (i.e. a job), the main thread will need to know that, and whenever a thread completes, check if it fullfill the needs of the job and then fire off whatever should happen after the job is complete.

     

    There really is no single best way to deal with background processing - except ensuring that the main thread is not blocked.

×