Fields being truncated. lazarus / 16-Databases ---------------------------------------------------------------------- Prime · 2023-04-08 07:10 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. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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(DBFIWadsFil ename).AsString,Length(FieldByName(DBFIWadsFilename).AsString)]);        END;        END;        Next;      END;    END;  FINALLY    WADFile.Free;  END;END;  The output I get on the debug log is : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [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. ---------------------------------------------------------------------- balazsszekely · 2023-04-08 09:59 1. Try this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  IF (NewPath <> OldPath) THEN BEGIN;   WADFile.LoadFromFile(NewPath);   IF (WADFile.IsIWAD) THEN   BEGIN;     Edit;     FieldByName(DBFIWadsFilename).AsString:=NewPath + #0; //<-add #0     Post;     Debug.Log('Replaced: %s, Length=%d',[FieldByName(DBFIWadsFi lename).AsString,Length(FieldByName(DBFIWadsFilename).AsString)]);   END; END; 2. If 1 is not working, then: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   IF (NewPath <> OldPath) THEN  BEGIN;    WADFile.LoadFromFile(NewPath);  IF (WADFile.IsIWAD) THEN    BEGIN;      Edit;      ST := CreateBlobStream(FieldByName('DBFIWadsFilename'), bmWrite);      try      ST.WriteBuffer(Pointer(NewPath)^, Length(NewPath));        ST.Position := 0;        Post;      finally        ST.Free;      end;      Debug.Log('Replaced: %s, Length=%d',[FieldByName(DBFIWadsFilename) .AsString,Length(FieldByName(DBFIWadsFilename).AsString)]);    END;  END;