Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to calculate the size of a record Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
calculate the size of a record 30-Oct-02
Category
Database Others
Language
Delphi 2.x
Views
184
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

How to calculate the size of a record

Answer:

Here's some code where StrucGrid is a StringGrid holding the table structure in 
DBD-like single char indentifiers in Col1 and, if applicable, field size in Col2. 
SpinEdit2 holds the blocksize in byte.
1   
2   procedure TMainFrm.CalculateRecordSizeClick(Sender: TObject);
3   var
4     MaxRecs, RecSize, RecsPerBlock, FreeSpace: Longint;
5     i: Integer;
6   begin
7     RecSize := 0;
8     with StrucGrid do
9     begin
10      for i := 0 to pred(RowCount) do
11      begin
12        case Cells[1, i][1] of
13          'A': RecSize := RecSize + StrToInt(Cells[2, i]);
14          'D', 'T', 'I', '+': RecSize := RecSize + 4;
15          'N', '$', 'Y', '@': RecSize := RecSize + 8;
16          'M', 'B', 'F', 'O', 'G': RecSize := RecSize + 10 + StrToInt(Cells[2, i]);
17          'S': RecSize := RecSize + 2;
18          'L': RecSize := RecSize + 1;
19        end;
20      end;
21    end;
22    RecsPerBlock := (SpinEdit2.Value - 6) div RecSize;
23    FreeSpace := (SpinEdit2.Value - 6) - (RecSize * RecsPerBlock);
24    MaxRecs := 65536 * RecsPerBlock;
25    ShowMessage('Record Size is: ' + IntToStr(RecSize) + ' bytes' + #13#10
26      + 'Records per Block: ' + IntToStr(RecsPerBlock) + #13#10
27      + 'Unused Space per Block: ' + IntToStr(FreeSpace) + ' bytes' + #13#10
28      + 'Max No of Records in Table: ' + FormatFloat('###############,', MaxRecs));
29  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC