I have a Palm app that stores data in 302 byte records. The data consists of a few bytes of header info followed by raw communications dumps (in other words, fairly unstructured). I'm accessing the data this way (taken from the AddressBook demo code).
V := RecordTable.Fields[0].AsVariant;
For I := VarArrayLowBound(V,1) to VarArrayHighBound(V,1) Do
S := S + '<' + IntToHex(V[I],2) + '>';
if S <> '' then
Writeln(f, S);
Writeln(f, '--------------------');
Is this the best way? Or is there a better way? The data has nulls in it, so I didn't think using a fixed string will be best.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Another way to handle this kind of thing is rather than using an AsVariant call, write a field read event handler which takes in the raw data for the record and stores it in something a bit more resources friendly than a variant. But unless you're dealing a large number of records in one go, you won't see much difference in speed either way.
Merry Christmas :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
pData is a pointer to the entire record being read in
DataSize is the total size of the record
FieldIndex is the index of the field currently being read in
DataPos is the current position in the record the field reader is up to
Data needs to be passed a string representation of the field data
So in turns of reading fields you have two options. First of all, you can simply use Abort to get the standard field reader to handle reading a particular field.
Secondly, you can provide your own handler. In this case, you should start reading data in from the address location of pData + DataPos.. however many bytes represent your field, and afterwards increment DataPos by that many bytes, so the field reader knows where the following field will start in the record.
Finally, Data should be returned a string representation of the field. This isn't mandatory - if your field is a complex data type, you can always just return an empty string for the field and instead, as I previously suggested, fill out a global data structure with the field data.
Paul.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a Palm app that stores data in 302 byte records. The data consists of a few bytes of header info followed by raw communications dumps (in other words, fairly unstructured). I'm accessing the data this way (taken from the AddressBook demo code).
V := RecordTable.Fields[0].AsVariant;
For I := VarArrayLowBound(V,1) to VarArrayHighBound(V,1) Do
S := S + '<' + IntToHex(V[I],2) + '>';
if S <> '' then
Writeln(f, S);
Writeln(f, '--------------------');
Is this the best way? Or is there a better way? The data has nulls in it, so I didn't think using a fixed string will be best.
Another way to handle this kind of thing is rather than using an AsVariant call, write a field read event handler which takes in the raw data for the record and stores it in something a bit more resources friendly than a variant. But unless you're dealing a large number of records in one go, you won't see much difference in speed either way.
Merry Christmas :)
Would this be put in the OnReadField event of the TpfgPalmRemoteTable? What are each of the paramaters for and how should they be manipulated?
pData: Pointer;
DataSize: Integer;
FieldIndex: Integer;
var DataPos: LongWord;
out Data: string
pData is a pointer to the entire record being read in
DataSize is the total size of the record
FieldIndex is the index of the field currently being read in
DataPos is the current position in the record the field reader is up to
Data needs to be passed a string representation of the field data
So in turns of reading fields you have two options. First of all, you can simply use Abort to get the standard field reader to handle reading a particular field.
Secondly, you can provide your own handler. In this case, you should start reading data in from the address location of pData + DataPos.. however many bytes represent your field, and afterwards increment DataPos by that many bytes, so the field reader knows where the following field will start in the record.
Finally, Data should be returned a string representation of the field. This isn't mandatory - if your field is a complex data type, you can always just return an empty string for the field and instead, as I previously suggested, fill out a global data structure with the field data.
Paul.
Oh, and Happy New Year!
:)