Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6818763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:13:08+00:00 2026-05-26T21:13:08+00:00

I have an event in a component (VCLZip) that uses the comp type, but

  • 0

I have an event in a component (VCLZip) that uses the comp type, but to display the result as a string I think I need to convert the comp value to int64, but I can not find a way to do so. Is there a way to convert a comp value to int64? or is there a different way to display a comp value as a string with commas … maybe Format?

function FormatKBSize( Bytes: Cardinal ): string;
{ Converts a numeric value into a string that represents the number expressed as a size value in kilobytes. }
var
arrSize: array [ 0 .. 255 ] of char;
begin
   { explorer style }
   Result := '';
   { same formating used in the Size column of Explorer in detailed mode }
   Result := ShLwApi.StrFormatKBSizeW( Bytes, arrSize, Length( arrSize ) - 1 );
 end;

procedure TFormMain.VCLZip1StartZipInfo( Sender: TObject; NumFiles: Integer; TotalBytes: Comp;
  var EndCentralRecord: TEndCentral; var StopNow: Boolean );
var
  Tb: int64;
begin
  InfoWin.Lines.Add( '' );
  InfoWin.Lines.Add( 'Number of files to be zipped: ' + IntToStr( NumFiles ) + '...' );
  Tb := TotalBytes; // <= this will not compile
  Tb := Int64(TotalBytes); // <= this will not compile
  InfoWin.Lines.Add( 'Total bytes to process: ' + FormatKBSize( Tb ) + '...' );
 end;

Edit – this seems to work but is there a better way?

InfoWin.Lines.Add( Format( '%n', [  TotalBytes ] ) );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:13:08+00:00Added an answer on May 26, 2026 at 9:13 pm

    The Comp type is an integer type but it is classified as a real. Thereby the compiler may not allow you to cast it directly to an Int64, nor assign it. You have to convert it. Try to use Trunc() to convert it to an Integer type.

    You may also try to use the absolute directive to have an Int64 variable share the same address as the Comp variable:

    procedure TFormMain.VCLZip1StartZipInfo( Sender: TObject; NumFiles: Integer; TotalBytes: Comp; 
      var EndCentralRecord: TEndCentral; var StopNow: Boolean ); 
    var 
      Tb: Int64 absolute TotalBytes;
    

    It should work although I usually don’t like it too much because a cast/conversion is easy to spot in code, an absolute declaration may not be seen easily if the code is long enough.

    A third solution is to declare a record:

    CompRec = record
      I64: Int64;
    end;
    

    and then the cast works:

    Tb := CompRec(TotalBytes).I64;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set the itemRollOver and itemRollOut event listeners on a List component, but
I have an event handler that needs to determine a type and execute code
I have a design and run-time component that contains a large number of event
I'm using an event-scope component as a view controller. I need to have an
I have a component I created that works like a Viewstack but the next
I have a component that determines a value on a postback event. protected void
I have a s:List component. I want to handle a click event to know
I have event manager process that dispatches events to subscribers (e.g. http_session_created, http_sesssion_destroyed). If
I have some event handler on a boundary class that manages a persistence mechanism
I have an event handler that will remove an element from a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.