Page 1 of 1

Lazarus – Convert Cardinal Lo and Hi to Int64 the easy way

Lazarus – Convert Cardinal Lo and Hi to Int64 the easy way

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
Examples: "MacOS X - Your question", "MS Word - Your Tip or Trick".

Please note that switching to another language when reading a post will not work!
Posts will not have a translated counterpart.




RSS Feed

Home Forums Software Development Delphi, Lazarus, Free Pascal Lazarus – Convert Cardinal Lo and Hi to Int64 the easy way

This topic contains 0 replies, has 1 voice, and was last updated by  hans 2 weeks, 4 days ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • 11833

    hans
    Keymaster

    One of those things I do not do every day …

    So I have a record, from an external library, that holds a 32 bit Lo and Hi (cardinal) to represent a Int64 number …
    How do I convert this to a regular Int64 so I can work with it?

    Lazarus Pascal comes with TONS of handy little tools, and Int64Rec is of of them.
    Int64Rec, found in the unit SysUtils, is a Record describing an Int64 value and can be used as such by using typecasting:

    var
      MyVar:Int64;
    ...
    begin
      ...
      Int64Rec(MyVar).Hi := somerecord.hi32;
      Int64Rec(MyVar).Lo := somerecord.lo32; ...
      WriteLn(IntToStr(MyVar));  // do something with the value of MyVar
      ...

    By assigning the Hi and Lo values, the actual value of MyVar is now defined.

Viewing 1 post (of 1 total)



You must be logged in to reply to this topic.