Solved

Data Structures | Follow Up

Posted on 2004-08-01
1
204 Views
Last Modified: 2010-04-05
Q is follow up of http:Q_21077801.html

Detailing a bit of Dynamic Arrays and how to get the size of them plus some tips and tricks...
0
Comment
Question by:Cerf
1 Comment
 
LVL 33

Accepted Solution

by:
Slick812 earned 250 total points
ID: 11690698
I will guess that you need the sizeOf for some kind of memory copy of array data?
if you have used fixed arrays you can get the array Data by the array variable's pointer address

var
aryFixed: TPMem51;

begin
CopyMemoy(@aryFixed, pPointer, SizeOf(aryFixed));
 - - - - - - - - -

but this will NOT work with dynamic arrays because the variable is jus a pointer to a delphi reference that handles the dynamic array, to use a pointer location for a dynamic arrat, I use the address of the first element

var
 _tData: Array of Word;

begin
// setlength and whatever
 pData := @_tData[0]; // first element of array for memory address od the array data


however, a SizeOf( ) for ANY TObject, or dynamic array (a String type is a dynamic array) it will ALWAYS return 4 , because these Objects and dynamic arrays are Pointers, because objects and dyn arrays are ReAllocated memory blocks,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now