Page 1 of 1
Forum

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.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - Convert Cardinal Lo and Hi to Int64 the easy way

1 Posts
1 Users
0 Reactions
2,679 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

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.


   
ReplyQuote
Share: