Board index » delphi » const array of xxx function parameters and records

const array of xxx function parameters and records

Claire <> wrote in message
> Hi

> Ive an event defined as follows

> TOnFinishedEvent = procedure(const Results : Array of TBusPacket;
>     ErrorCode : TBusErrorCode; ErrorPacket : integer;
>     Reference : integer) of object;

> At the end of some reading from a com port, I pass the results back using
> this callback event.
> The results are held as a list of record buffer pointers in a TList object.
> The records are of type TBusPacket.

> type TBusPacket = packed Record
>     nBusAddress : Byte;
>     nBusCommand : Byte;
>     case boolean of
>     true :(fFloatData : Single);
>     false:(nLongData  : LongInt);
>   end;

> When my object wants to pass these records back in the OnFinished event, I
> have to convert them into the "Results" parameter - ie an array of
> TBusPacket.

?  Can you not just pass the TList back?  If the event handler needs an array, can
you not store the incoming data in an array rather than a TList?

I'm sorry - perhaps I do not understand your question too well, (especially the
variants bit - why a variant array?  The data in the TBusPacket seems to clearly
defined.  Using variants seems like unnecessary data obfuscation, (and slow).



Re:const array of xxx function parameters and records

Thanks Martin :-) ( posted it to wrong group anyway oops)
You're right. I changed it to a buffer pointer after thinking about it.



2.0 Beardies, 2.1 BCI, 1.0 Burm, 2.0 Corn, 0.0.2 Garter, 1.1 Hogg Island,
1.1 Hog Nose, 1.1 {*word*76}, 1.1 Carpet, 1.0 Pueblan, 1.0 King, 2.0 Royal,
1.0 BRB, 1.2 Emperor Scorpion,0.0.1 Goliath, 0.0.1 Red Knee,
0.0.1 Salmon Pink, 1.0 Psychoanalyst

Other Threads