gardenia
asked on
Can I use Pointer as an Array in pascal like C++?
I want to use an FileMaping Pointer as an Array of Record,
But I dont know how to do that,somebody help me?
But I dont know how to do that,somebody help me?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
gardenia:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
split points between AvonWyss and TOndrej
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thanks,
geobul
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
split points between AvonWyss and TOndrej
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thanks,
geobul
EE Cleanup Volunteer
The delphi runtime declares pointers to a couple of similar arrays (ex: PByteArray, PCharArray) that are often used, in D2 & D3 in particular, to approximate dynamicaly resizable arrays. They're declared like so (I don't have the source handy, but if my implementation isn't detail perfect, the concept stands):
TByteArray = array[0..32767] of byte;
PByteArray - ^TByteArray;
so you can do this:
var
bytes : PByteArray;
index : integer;
begin
getMem(bytes,1000);//now we've got 0..999 elements
index := 999;
bytes[index] := random(256);//bytes[999] is now in 0..255
dispose(bytes);
So you can extend this like so:
RMyRec = record
fooStr : array[0..10] of char;
fooInt : integer;
end;
TMyRecArray = array[0..some_big_number] of RMyRec;
PMyRecArray = ^TMyRecArray;
var
recs : PRecArray;
ix : integer;
begin
getMem(recs,sizeOf(RMyRec)
GL
Mike