I have a conduit to sync the Datebook with a mysql database. With Version 1.14 there was no problem in that.
After Switching to Delphi 7 and Version 1.16,
the records written to the Palm don't have the description nor the note field set.
This seems to happen on post, and i think its related the writefield-function.
Here is my custom writefield Function
procedure TDataModuleMain.pfgPalmRemoteTableDate3WriteField(Sender: TObject;
FieldIndex, DataPos: Integer; out Data: Variant);
var
bFieldExist : boolean;
iFlags : integer;
begin
iFlags := pfgPalmRemoteTableDate.FieldByName('Flags').AsInteger;
bFieldExist := false;
case FieldIndex of
//0..1 : bFieldExist:= false;
0..3 : bFieldExist := true;
4,5 : bFieldExist := (iFlags And 64) > 0;
6..12 : bFieldExist := (iFlags And 32) > 0;
13 : bFieldExist := (iFlags And 8) > 0;
14 : bFieldExist := (iFlags And 8) > 0;
15 : bFieldExist := (iFlags And 4) > 0;
16 : bFieldExist := (iFlags And 16) > 0;
end;
if bFieldExist then
Abort;
Data := VarArrayCreate([-1,-1],varByte);
Data[-1] := 0;
Normally, this should handle to create the additional infos like note and description that I need
Anyone has an idea what i have done wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't see anything obviously wrong with it. In cases like this, I find it a good idea to put breakpoints in the LocalToRemoteRecord near the end - you can then use the View CPU view to see the raw bytes of the record that's being written out. It's always possible that an alignment problem is causing fields to go out of place.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Tried to see anything in CPU View, but I can't analyse that. I gone through but I can't find the raw bytes of my record...
I thought there would be a problem with the field-definitions but I can read ALL Entries normally from the palm. Even with the Notes Field.
The thing I think wich could be a Problem are my Flag-Settings.
I tried to set the Flag in both ways:
aPalmTable.FieldByName('Flags').AsInteger := iFlags;
aPalmTable.Fields.Flags := iFlags;
You mentioned Alignment Problems. Do I need to set any alignment?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First of all, the Fields.Flags variable is strictly for the Palm specific flags for a record. This includes whether it's been modified, deleted, etc. The first one is correct. Secondly, if you're saving out a datebook record, there are two things you'll need to be aware of:
* Your flags variable needs to be built up of bitfields flagging which fields are being included. Check out the set of APPTFLAG_* variables and the ApptFlagArray in the datebook example to get the values to join based on which datebook values you're including in your record.
* Have a write field event handler to skip writing out fields that aren't being included. This is important - the datebook expects fields not flagged in the flags not to be present. Even a blank string being written out for an unused field would causes problems in later decoding, since it would make the remaining fields out of position.
The alignment issue shouldn't be an issue, so you can probably ignore it. As I said earler, the best method is to use the View CPU functionality of Delphi to display the contents of a raw record that will be written out, and check byte by byte that the record is legitimate. Also try immediately reading the record back in after writing it, and use debugging to see how your conduit parses the record, to make sure it was written out in the correct format. If problems occur, it will give you a good idea of what part of the record you incorrectly wrote out.
Regards,
Paul.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just checked my function wich fills the actual data - like i said, the same function already worked with an older version.
I adapted the Read Methods like your example, wich work flawless.
I now changed the Flags in my write-method with the APPTFLAG_* by combining them with + after checking if there really IS Data in that field.
CODE ------------------------------------------------------------------
aPalmTable.FieldByName('Note').AsString := StringReplace(sNote,#13+#10,#10,[rfReplaceAll]);
if sNote <> '' then
iFlags := iFlags + ApptFlagArray[afNote];
if bPrivat then
aPalmTable.FieldByName('Flags').AsInteger := iFlags + eRecAttrSecret
else
aPalmTable.FieldByName('Flags').AsInteger := iFlags;
I have a conduit to sync the Datebook with a mysql database. With Version 1.14 there was no problem in that.
After Switching to Delphi 7 and Version 1.16,
the records written to the Palm don't have the description nor the note field set.
This seems to happen on post, and i think its related the writefield-function.
Here is my custom writefield Function
procedure TDataModuleMain.pfgPalmRemoteTableDate3WriteField(Sender: TObject;
FieldIndex, DataPos: Integer; out Data: Variant);
var
bFieldExist : boolean;
iFlags : integer;
begin
iFlags := pfgPalmRemoteTableDate.FieldByName('Flags').AsInteger;
bFieldExist := false;
case FieldIndex of
//0..1 : bFieldExist:= false;
0..3 : bFieldExist := true;
4,5 : bFieldExist := (iFlags And 64) > 0;
6..12 : bFieldExist := (iFlags And 32) > 0;
13 : bFieldExist := (iFlags And 8) > 0;
14 : bFieldExist := (iFlags And 8) > 0;
15 : bFieldExist := (iFlags And 4) > 0;
16 : bFieldExist := (iFlags And 16) > 0;
end;
if bFieldExist then
Abort;
Data := VarArrayCreate([-1,-1],varByte);
Data[-1] := 0;
Normally, this should handle to create the additional infos like note and description that I need
Anyone has an idea what i have done wrong?
I can't see anything obviously wrong with it. In cases like this, I find it a good idea to put breakpoints in the LocalToRemoteRecord near the end - you can then use the View CPU view to see the raw bytes of the record that's being written out. It's always possible that an alignment problem is causing fields to go out of place.
Tried to see anything in CPU View, but I can't analyse that. I gone through but I can't find the raw bytes of my record...
I thought there would be a problem with the field-definitions but I can read ALL Entries normally from the palm. Even with the Notes Field.
The thing I think wich could be a Problem are my Flag-Settings.
I tried to set the Flag in both ways:
aPalmTable.FieldByName('Flags').AsInteger := iFlags;
aPalmTable.Fields.Flags := iFlags;
You mentioned Alignment Problems. Do I need to set any alignment?
Hi there,
First of all, the Fields.Flags variable is strictly for the Palm specific flags for a record. This includes whether it's been modified, deleted, etc. The first one is correct. Secondly, if you're saving out a datebook record, there are two things you'll need to be aware of:
* Your flags variable needs to be built up of bitfields flagging which fields are being included. Check out the set of APPTFLAG_* variables and the ApptFlagArray in the datebook example to get the values to join based on which datebook values you're including in your record.
* Have a write field event handler to skip writing out fields that aren't being included. This is important - the datebook expects fields not flagged in the flags not to be present. Even a blank string being written out for an unused field would causes problems in later decoding, since it would make the remaining fields out of position.
The alignment issue shouldn't be an issue, so you can probably ignore it. As I said earler, the best method is to use the View CPU functionality of Delphi to display the contents of a raw record that will be written out, and check byte by byte that the record is legitimate. Also try immediately reading the record back in after writing it, and use debugging to see how your conduit parses the record, to make sure it was written out in the correct format. If problems occur, it will give you a good idea of what part of the record you incorrectly wrote out.
Regards,
Paul.
I just checked my function wich fills the actual data - like i said, the same function already worked with an older version.
I adapted the Read Methods like your example, wich work flawless.
I now changed the Flags in my write-method with the APPTFLAG_* by combining them with + after checking if there really IS Data in that field.
CODE ------------------------------------------------------------------
aPalmTable.FieldByName('Note').AsString := StringReplace(sNote,#13+#10,#10,[rfReplaceAll]);
if sNote <> '' then
iFlags := iFlags + ApptFlagArray[afNote];
if bPrivat then
aPalmTable.FieldByName('Flags').AsInteger := iFlags + eRecAttrSecret
else
aPalmTable.FieldByName('Flags').AsInteger := iFlags;
CODE ------------------------------------------------------------------
After changing that, my conduit stops with "A mapped field went beyond the end of the physical record".
I checked my fields and alignment, everything is equal to the example.