Hi all,
I'm using the Zeos components to access a sqllite database and am having the following problem in modifying fields in my program.
PROCEDURE TDoomDataModule.FixIWADPaths;
VAR IWADNo : INTEGER;
OldPath : STRING;
NewPath : STRING;
WADFile : TWadBin;
BEGIN;
FErrors.Clear;
WADFile:=TWadBin.Create;
TRY
WITH ZIWADQuery DO
BEGIN;
First;
FOR IWADNo:=0 TO (RecordCount-1) DO
BEGIN;
OldPath:=FieldByName(DBFIWadsFilename).AsString;
NewPath:=FindGameFile(OldPath,FFTryAll);
Debug.Log('OldPath: %s, Length=%d',[OldPath,Length(OldPath)]);
Debug.Log('NewPath: %s,Length=%d',[NewPath,Length(NewPath)]);
IF (NewPath <> OldPath) THEN
BEGIN;
WADFile.LoadFromFile(NewPath);
IF (WADFile.IsIWAD) THEN
BEGIN;
Edit;
FieldByName(DBFIWadsFilename).AsString:=NewPath;
Post;
Debug.Log('Replaced: %s, Length=%d',[FieldByName(DBFIWadsFilename).AsString,Length(FieldByName(DBFIWadsFilename).AsString)]);
END;
END;
Next;
END;
END;
FINALLY
WADFile.Free;
END;
END;
The output I get on the debug log is :
[127.0.0.1] OldPath: G:\games\doomsday\Run\jHeretic\blasphem.wad, Length=43
[127.0.0.1] NewPath: /usr/local/share/doom/wads/blasphem.wad,Length=39
[127.0.0.1] Replaced: /usr/local/share/doom/wads/blasphem.wa, Length=38
As you can see the posted string is truncated by one character, when read back. I don't have this problem if I edit the field with one of the visual components, or if I execute a query which replaces the values.
The field I'm replacing is defined as blob, so it shouldn't be an issue of overflowing the database field. Also if I edit that field in another part of the code and add the missing last character that replacement works.
Anyone have any idea what is going on here.
Cheers.
Phill.