azsd
asked on
how to use dynamic array in packed record like fixed array?
Hi,I have a packed record here:
=========================
tagCngpTLV = packed record
Tag:WORD;
Length:WORD;
Value:Array of Byte;
Reserve:Array[0..7] of Byte;
end;
=========================
I have an record like this:
CngpTLV1:tagCngpTLV
Tag:$0001,
Length:$0006;
Value:$FF,FF,FF,FC,00,00
Reserve:$00,00,00,00,00,00 ,00,00
if I use CngpTLV1 as a buffer to insert it into a stream,the data in Value postion became a ^Array pointer.
How Can I use it like an
Tag:WORD;
Length:WORD;
Value:Array[0..5] of Byte;
Reserve:Array[0..7] of Byte;
record?
in fact I have more complex record struct so I can't use another buffer and calc the each items' postion&size then copy into it one by one.
=========================
tagCngpTLV = packed record
Tag:WORD;
Length:WORD;
Value:Array of Byte;
Reserve:Array[0..7] of Byte;
end;
=========================
I have an record like this:
CngpTLV1:tagCngpTLV
Tag:$0001,
Length:$0006;
Value:$FF,FF,FF,FC,00,00
Reserve:$00,00,00,00,00,00
if I use CngpTLV1 as a buffer to insert it into a stream,the data in Value postion became a ^Array pointer.
How Can I use it like an
Tag:WORD;
Length:WORD;
Value:Array[0..5] of Byte;
Reserve:Array[0..7] of Byte;
record?
in fact I have more complex record struct so I can't use another buffer and calc the each items' postion&size then copy into it one by one.
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.
ASKER
quote:
I want to get an datastream like this for use,not "wan't"
I want to get an datastream like this for use,not "wan't"
ASKER
I have aready alloced 6 byte Value by setlength and Move()-ed some datas in record,
I wan't to get an datastream like this for use:
$01,00;$06,00;$FF,FF,FF,FC
and now I use the @CngpTLV1 as an buffer pointer,
the data in memory like
$01,00;$06,00;$28,00,60,00
I had to use code like:
var
newbuf:array of byte;
begin
//CngpTLV1 ready
SetLength(newbuf,sizeof(Cn
FillChar(newbuf,Length(new
Move(CngpTLV1,newbuf[0],si
Move(CngpTLV1.Value[0],new
Move(CngpTLV1.Reserve,newb
//Send(clientsocket, newbuf[0],Length(newbuf),0
//or save the buf to disk
end;
In reality application,there some more then 40 member record with about 6,7 dynamic length,
I want to kick my screen usually.
I tried to use follow codes:
Tag:WORD;
Length:WORD;
Value:Array[0..Length-1] of Byte;
Reserve:Array[0..7] of Byte;
sure I was shamely get grammer error.