Recent

Author Topic: How to write binary data to string field : TDbf  (Read 3125 times)

j111

  • New member
  • *
  • Posts: 8
How to write binary data to string field : TDbf
« on: May 27, 2008, 08:58:43 pm »
Hello.

I have created a sample dbf table with one field of Char type and 2 bytes length.
And write sample code below. And when I write value of my Word variable to it, TDBf corrupts data. I saw at dbf in hex editor and i think that 00x0 chars it translates to 20x0. How Can I write any data I want without processing them according to field data type?

Code: [Select]

program testbin;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  Dbf
  { add your units here };

var
  f : TDbf;
  si : word;
begin
  si := 1;

  f := TDbf.Create(nil);
  f.TableName := C:\lazarus_projects\test_write_bin_val_str_field\test.dbf';

  f.Open();

  f.Append();
  f.Fields[0].SetData(@si,True);
  f.Post();

  f.Close();
 

end.

 

TinyPortal © 2005-2018