Jump to content

Alexander Elagin

Members
  • Content Count

    198
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by Alexander Elagin


  1. I have used devices from Kvaser, IXXAT and some others. Kvaser has a superb support library (CANLib SDK) which includes Delphi interface module, their software model is very simple and elegant. IXXAT also used to have one, but I have not touched it since version 2.18 as the later versions of their VCI interface were incompatible with 2.x branch. Kvaser drivers implement virtual CAN channels which helps debugging when no real hardware is available.


  2. There are two pairs of methods which differ only in register (getDocumentData / GetDocumentData and getDocumentStatus / GetDocumentStatus), that's why the imported module does not compile. Simply change these definitions like this, marking them as overloaded:

        function  getDocumentStatus(const parameters: getDocumentStatus2): getDocumentStatusResponse2; stdcall; overload;

    and the unit will at least compile successfully. I have no idea if it will work as intended - hopefully yes because the parameters differ.

    As for the "cannot unwrap" note, this is pretty normal. This means that the importer could not extract individual parameters and imported them instead together as a class, this usually does not cause problems. Just take care with memory management.

     

    • Thanks 1

  3. 1 hour ago, Sherlock said:

    Not to be "that guy" but, um... it would seem my initial dates where indeed ISO 8601 formatted. So my guess now is that the DUnitX used in D11.3 is more than two years old?

    Almost correct... you missed "T" character between the date and time parts:

    2023-06-22 17:44:23.456

    should be

    2023-06-22T17:44:23.456

    to represent a valid ISO 8601 date. (And probably a timezone but it is usually not required)

     


  4. 2 hours ago, milurt said:

    i see nowhere sizeof(char) in my program.

    why is a +1 a +2?

    Because you have this declaration:

    ballpointer: PChar;

    PChar is an alias for PWideChar. WideChar is 2 bytes long. When pointer arithmetics is used, all operations take into account the real size of the data type the pointer points to. Thus, this statement:

    ballpointer := ballpointer+1;

    is in fact compiled and executed as

    ballpointer := ballpointer + 1*SizeOf(WideChar);

    and you have your pointer correctly pointing to the next WideChar in memory.

     

    This is really easy to check with a simplest program:

    program Project1;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils;
    var
      P: PChar;
    begin
      GetMem(P, 20);
      WriteLn(Format('P = %8x', [NativeUInt(P)]));
      P := P + 1;
      WriteLn(Format('P = %8x', [NativeUInt(P)]));
      ReadLn;
    end.

    You'll see that second value printed is greater than the first by 2 in any modern Delphi version.

    (Yes, I know there is a memory leak but this is just a demonstration).


  5. Quoting the aforementioned RFC 2550:

    Quote

     

    
       There are a number date comparison problems that are beyond the scope
       of this specification.
       (...)
       3) Continued existence of Earth-centric time periods (year, day,
          etc.) are problematical past the up-coming destruction of the
          solar system (5-10 billion years or so).  The use of atomic-time
          helps some since leap seconds are no longer an issue.
       4) Future standards and methods of synchronization for inter-planetary 
          and inter-galactic time have not been agreed to. 
       5) Survivability of dates past the end of the universe is uncertain. 

     

     


  6. Just be sure that you never ever implement any business logic in visual form units (you know, those OnClick handlers...). Everything must be implemented in non-visual classes (including datamodules) not depending on any VCL units. Forms must be used only to call that functionality and display the results, if any. Thus you will finally get a nice set of units which can be further used anywhere, be it a UI-less server, console application, VCL or FMX.


  7. There is a nice example in the InnoSetup documentation:

    Quote

    FontInstall

    Tells Setup the file is a font that needs to be installed. The value of this parameter is the name of the font as stored in the registry or WIN.INI. This must be exactly the same name as you see when you double-click the font file in Explorer. Note that Setup will automatically append " (TrueType)" to the end of the name.

    If the file is not a TrueType font, you must specify the flag fontisnttruetype in the Flags parameter.

    It's recommended that you use the flags onlyifdoesntexist and uninsneveruninstall when installing fonts to the {autofonts} directory.

    If the installation is running in non administrative install mode, Windows 10 Version 1803 or later is required to successfully install a font.

    For compatibility with 64-bit Windows, fonts should not be installed to the {sys} directory. Use {autofonts} as the destination directory instead.

    Example:

    
    Source: "OZHANDIN.TTF"; DestDir: "{autofonts}"; FontInstall: "Oz Handicraft BT"; Flags: onlyifdoesntexist uninsneveruninstall

     

     


  8. Finalization sections are executed in the reverse order to initialization, so the first unit to initialize will be the last one to finalize.

    From the documentation:

    The Finalization Section

    The finalization section is optional and can appear only in units that have an initialization section. The finalization section begins with the reserved word finalization and continues until the end of the unit. It contains statements that are executed when the main program terminates (unless the Halt procedure is used to terminate the program). Use the finalization section to free resources that are allocated in the initialization section.

    Finalization sections are executed in the opposite order from initialization sections. For example, if your application initializes units A, B, and C, in that order, it will finalize them in the order C, B, and A.

    Once a unit's initialization code starts to execute, the corresponding finalization section is guaranteed to execute when the application shuts down. The finalization section must therefore be able to handle incompletely initialized data, since, if a runtime error occurs, the initialization code might not execute completely.


  9. A more or less easy solution would be to add the destructor call to the finalization section of Unit3:

    ....
    initialization
      tsTest := TStringList.Create; // or wherever it must be created
    finalization
      tsTest.Free
    end.

    And make sure that Unit3 is added to the project file before any form units:

    program Project1;
    
    uses
      VCL.Forms,
      Unit3 in 'Unit3.pas',
      Unit1 in 'Unit1.pas', {Form1}
    ....

    Not guaranteed but will probably work.

     


  10. 13 minutes ago, Ian Branch said:

    3.  Using a constructor.  Never knowingly done so.  I tried Dalija's constructor but it gives me an E@065 Unsatisfied forward or external declaration: 'TTracksAddEditForm.Create'. 

    It just means that you have to write the missing constructor for the TTracksAddEditForm:

    constructor TTracksAddEditForm.Create(AOwner: TComponent; const AsMode: string; AiAlbum: integer; const AsTrack: string);
    begin
      inherited Create(AOwner);
      sMode := AsMode;
      iAlbum := AiAlbum;
      sTrack := AsTrack;
    end;

  11. 12 minutes ago, Alexander Elagin said:

    Got it. Then alas, I do not think there is such option in Lazarus. I have never used it in Delphi, but it all depends on one's personal preferences and development style.

    I was wrong ;-( There are in fact options to fold and unfold: Alt-Shift-1 to Alt-Shift-9 fold blocks of appropriate level, Alt-Shift-0 unfolds all.

    3.thumb.png.5b11be76bfe7a28d8306962c380ccf53.png


  12. 4 hours ago, Uwe Raabe said:

    OT: This reminds me of the move to the new Galileo IDE with the docked layout, where people said they will stay with Delphi 7 forever. I still feel sorry for all of them who did.

    And after a few versions and much ranting the classic undocked layout had been reintroduced. Let's hope the same can happen again because I hate this new docked IDE where I cannot have several forms and code editor visible at once.


  13. A generic TStream has no idea how to store data, it is just an abstract class. Therefore any data written to it after this code snippet:

    Quote

    ms := TStream.Create;
      MarafillerDM.EMUInvQrySIGNATURE.SaveToStream(ms);

    are simply discarded.

    I'd replace the first line with this:

    ms := TMemoryStream.Create;

    The variable declaration can remain the same.

    • Like 1

  14. After a bit of googling I got the following information regarding DevExpress.

    1. While the management and a group of developers are located in USA, almost all development and support team are in Russia (namely, in Tula, Kaluga and St.Peterburg). A rather old article in Russian briefly introduces the company: https://habr.com/ru/company/developersoft/blog/104047/

    2. From this page we can find out the web address of the russian branch: https://www.developersoft.ru

    Exploring this site (description, portfolio, history...) it is easy to see that this is really the other face of DevExpress, or at least the company which does all the work.

    3. And now the most interesting statement from the mentioned page:

    Quote

    Компания приостанавливает на неопределенный срок найм и активную деятельность в прежнем объеме с 2 марта 2022 года.

    That is, the Company is suspending all hiring and operations indefinitely as of March 2, 2022.

     

    4. Conclusion. Given the current political and economical situation (first of all, blocking of virtually all payments between Russia and the western world, meaning that the developers cannot be paid) it means that either DevExpress management has to be able to relocate the development and support team somewhere outside the russian borders, or it has to hire an absolutely new team as a replacement, or cease any development until all this madness ends.

    All the information is from the internet, I'd prefer not to trust it 100%, but unfortunately it seems too matching to be true.

    • Thanks 5
    • Sad 1

  15. I have a zipped Virtual Treeview archive from 2004, it contains packages for Delphi 4 - Delphi 9 (2005?). If anybody is interested, I can share it. Also found the installer for VTV 4.8.7, dated 15.12.2010.

×