Jump to content

Lajos Juhász

Members
  • Content Count

    1073
  • Joined

  • Last visited

  • Days Won

    15

Posts posted by Lajos Juhász


  1. 23 minutes ago, Fr0sT.Brutal said:

    No, this was a non-DB-related question, just curiosity.

    The FD reference was just to give context the reason why I have to lock all my users to a specific code page (also a nice example a problem when you're dealing with an ansi database using Delphi).

     

    24 minutes ago, Fr0sT.Brutal said:

    CharInSet won't check whether a char is ASCII or not and codepage-dependent cases are possible that won't produce neither compile-time messages nor run-time errors

    it will:

     

    [dcc32 Warning] Unit1.pas(32): W1061 Narrowing given WideChar constant (#$045A) to AnsiChar lost information

     

    25 minutes ago, Fr0sT.Brutal said:

    Runtime exception in such a basic function doesn't look good

    There is no runtime problem. The compiler will try to convert unicode string to ansistring,  code points that cannot be represent in ansistring will be replaced with ? a well known behavior of windows.


  2. 2 minutes ago, Fr0sT.Brutal said:

    Btw, I wonder how do you check whether a char is a letter of a some language (f.ex. Norwegian, German)? They have not only latin chars but some additional which can't be declared with simple 'a'..'z'. You have to add them explicitly, like 'a'..'z', 'æ'?

    That's easy for me. I use FireDAC with settings to string fields to widestring (unicode). When writing back the data firedac requires that windows is set for non unicode language to be the correct codepage (simply ignores client and db codepage). Thus I know for sure that if I convert a unicode string it will use the correct codepage.

     

    This is going to work until the database is using code page. 


  3. There is no "unicode" set in Delphi. Using CharInSet will only work on Ansi. For example on my Windows this will not show true on my laptop:

     

    procedure TForm1.FormCreate(Sender: TObject);
    var
      a: char;
      s: string;
    begin
      a:='њ';
    
      if CharInSet(a, ['њ', 'а', 'м']) then
        ShowMessage('true');
    end;

    Here is the reason:

     

    [dcc32 Warning] Unit1.pas(32): W1061 Narrowing given WideChar constant (#$045A) to AnsiChar lost information

    [dcc32 Warning] Unit1.pas(32): W1061 Narrowing given WideChar constant (#$0430) to AnsiChar lost information
    [dcc32 Warning] Unit1.pas(32): W1061 Narrowing given WideChar constant (#$043C) to AnsiChar lost information

     


  4. TApplication.CreateForm in the first place must create the instance (when the formcreate is called) and just after can assign it to mainform.

     

    You can do

     

    TMainForm.FormCreate(Sender: TObject);

    begin

     .....

      MakeSurface(self);

     

    For me it's always a code smell when somebody uses a global variable or reference.

    • Like 1

  5. 2 hours ago, DelphiUdIT said:

    PAY ATTENTION: SqlQuery1 I think dynamically allocates Fields[1] and therefore your POINTER will be invalid after a new QUERY is executed.

    You should read the code: SQLQuery1.Fields[1].asInteger integer value of the field converted to a pointer.

     

    The problem here is that the id is not going to be a continous enumeration starting from 0.

    • Thanks 1

  6. For me this is working with VCL. I set the timer to 250ms.

     

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
    
    type
      TDirection = (dinone, diup, didown, dileft, diright);
    
      TForm1 = class(TForm)
        box: TShape;
        Timer1: TTimer;
        procedure Timer1Timer(Sender: TObject);
        procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
      private
        { Private declarations }
        fDirection: TDirection;
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    
    
    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      case key of
        ord('W'): fdirection:=diup;
        ord('A'): fDirection:=diLeft;
        ord('D'): fDirection:=diRight;
        ord('X'): fDirection:=diDown;
      else
        fDirection:=diNone;
      end;
    end;
    
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      case fDirection of
        diup : box.Top:=box.top-10;
        didown : box.Top:=box.Top+10;
        dileft: box.left:=box.Left-10;
        diright: box.Left:=box.Left+10;
      end;
    end;
    
    end.

     

    • Like 1

  7. You cannot hook up DB controls to an unidirectional query but that should not stop you from inspecting and saving it. 

     

    I am using FireDAC with ODBC driver from the first version (to connect to Informix database). The data is never corrupted. The only problem I am aware is when writing to database FireDAC ignores the database locale and uses the default Windows locale for non-unicode language to write data. 

    • Like 1

  8. I believe you would have to do that in Word:

     

    (WINDOWS) Microsoft Word 2010, 2013, 2016:
    1. Go to “File”
    2. Select “Info”
    3. Click on “Check for issues”
    4. Click on “Inspect document”
    5. In the “Document Inspector” dialog box, select the check boxes to choose the types of hidden content that you want to be inspected.
    6. Click “Remove All”
    7. Click “Close”
    8. Save the document.

     


  9. 24 minutes ago, omnibrain said:

    Doesn't matter in this case, because it's just an example, but definitily something to consider if it plays a role.

     

    Today it's an example. Tomorrow you or somebody else sees the code and use it in a real application. Copy paste errors are always a fun thing to search for or debug.

    • Like 1
×