Jump to content

haentschman

Members
  • Content Count

    210
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by haentschman


  1. Hi...:classic_cool:

    https://docwiki.embarcadero.com/Libraries/Seattle/en/System.IOUtils.TDirectory.GetCurrentDirectory

    Quote

    Returns the current working directory.

    Use GetCurrentDirectory to get the current directory

    Current working directory:  99% <> ExtractFilePath(Application.ExeName) 

    Quote

    or the WIN API SetCurrentDirectory was called somewhere

    Example: Current working directory can be "C:\Windows\System32" or else a special folder...

     


  2. Hi...😎

     

    try this...😉

    if not Qry.FieldByName('Picture').IsNull then
    begin
      Stream :=  TMemoryStream(Qry.CreateBlobStream(Qry.FieldByName('Picture'), bmRead));
      try
        Contact.Picture := TMemoryStream.Create;
        Contact.Picture.LoadFromStream(Stream);
      finally
        Stream.Free;
      end;
    end;

    before...Contact.Picture = nil 😉

    • Thanks 1

  3. Hi...:classic_cool:

     

    Quote

     

    
    MyDialog := TTaskDialog.Create(Self);
    try
      MyDialog.Title := 'Warning!';
      MyDialog.Text := 'Relevant/selected Records prior to ' + sArchivedDate + ' have been Archived!' + #13 + 'This may make the figures inaccurate!';
      MyDialog.CommonButtons := [tcbOk];
      MyDialog.Execute;
    finally
      MyDialog.Free;
    end;

     

    ...this is right. 😉

     

    Quote

    To me it is just another tool in the tool box of the language.

    ...but the language has also changed. "with" is 90's. :classic_wacko: The "new" TRect was imho the first problem in this case. The structure of TRect was changed. Some "with" had the false scope...AccessViolation.   

     

    The biggest problem with "with" is:

    Quote

    One annoyance with using with is that the debugger can't handle it. So it makes debugging more difficult.

    with TTaskDialog.Create(Self) do
    try
      Title := 'Warning!';
      Text := GetTextFromFunction;
      CommonButtons := [tcbOk];
      Execute;
    finally
      Free;
    end;

    ...and now you set a breakpoint on "Excecute". Then read the variable content from "Text" under the mouse...you see nothing. :classic_wacko:

    Quote

    By the way, it will allow easier debugging: you can put a breakpoint, then point your mouse on Obj or Nested directly to get the internal values.

    More Info ( June 26, 2007 :classic_tongue:)

    https://blog.marcocantu.com/blog/with_harmful.html

     

    :classic_cool:


  4. Quote

    to using 'With', I do believe it has its place.

    In the modern Delphi...always NO.

    see uses TRect - https://stackoverflow.com/questions/71419/why-should-i-not-use-with-in-delphi :classic_huh:...and other.

    procedure MainForm.ButtonClick(Sender: Object)
    begin
    with TMyForm.Create(nil) do
    try
    	ShowModal;
    finally
    	Free;
    end;

    ...this means a rebuild of the code if complexity increases...why not "right" with instance variable. :classic_cool:

    ...and the variable display in the debugger does not work.:classic_wacko:

     

    Quote

    The biggest being that with actually reduces readability. NOTE: Less code (using with) does not automatically improve readability. It reduces it because it's no longer explicit what the scope of identifiers within a with block refer to.

     

    I am out of this discussion... :classic_tongue:


  5. Hi...:classic_cool:

     

    ...always try/finally! :classic_tongue: In case of error IdHTTP.free is not executed because skipped to the end

     

    Better:

     IdHTTP := TIdHTTP.Create(nil);
     try
       try
         S := IdHTTP.Get(Link);
         result := S;
       except
         ShowMessage('Could not get VERSION information');
       end;
    finally
      IdHTTP.Free;
    end;

     


  6. Hi...😎

    Quote

    I must have an id field.... 

    ...always! Per table or better per database. 😉 Per database = the ID is complete unique.

     

    id varchar(10) not null primary key,

    ... never string!

     

    ID int not null primary key,

     


  7. Hi...welcome here. :classic_cheerleader:

     

    First:

    Quote

    data to an Access database

    ...why ACCESS and ADO? 🤢 ...😉

     

    For the future: can you change the database? 😉

     

    const ISQL = 'INSERT INTO JobCard (ID ,OrderNo ,JobName)  VALUES ( :ID :OrderNo, :JobName)';

    ...better than the ADD orgy. It is even better to store the SQL outside the "form" or "datamodule" as SQL file. 😉

    Quote

    I am a newbie

    ...i know. No problem. Learning by doing... 😉


  8. Quote

    On 11/3/2021 at 9:00 AM, Daniel said:  I gave the whole project to another MVP, I will ask about the progress.

    Two month...What is the status? Which MVP?

    Quote

    at the moment it's the adaption to the high-dpi settings

    Imho 10% uses high-dpi. :classic_huh:

    Quote

    The code itself works

     ...make a version without high-dpi. All waiting! Please...:classic_cheerleader:

     

    PS: why don't you publish it on github or something...?

×