OSGeo / shapelib

Official repository of shapelib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ShapefileII.pas needs help

josimaralves opened this issue · comments

Hello, has anyone had problems with the use of the pascal version of the file 'ShapefileII.pas'?
I'm trying to create a shp file and the associated .DBF file using Delphi. I can create the SHP and DBF file, but I cannot add string data to the DBF file. I used the steps described in the example file 'dbfadd.c' using the function 'DBFWriteStringAttribute' and 'DBFWriteIntegerAttribute'. The function does not return any errors, but the string field in DBF file is not updated.
Please, can anyone help me?
Here my code:

//add data
FDBFHandle := DBFOpen(pAnsichar(FileNameDBF), pAnsichar('r+b')); //open a DBF file created
if FDBFHandle = nil then
exit;
iRecord:= DBFGetRecordCount(FDBFHandle);
DBFWriteIntegerAttribute(FDBFHandle, iRecord, 0, 99 ); //works fine
DBFWriteStringAttribute (FDBFHandle, iRecord, 1, PAnsichar('TEST' ));//NOT WORK BUT RETURN TRUE
//Using PAnsistring also not work
DBFClose(FDBFHandle);

Solved. Sorry, I found that the problem was due to procedure DBFCreate and not due to DBFWriteStringAttribute. The field was created as an Integer and not as a string. So, the DBFWriteStringAttribute save 0 value.