Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-06

Tdbf Memo Field Issue, 2.6.2 vs 2.6.4

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David Copeland

Hi,

I think this is a bug

I wrote a simple program using Tdbf to export a dBase IV/w. Memo file to a csv file. Accessing the memo field with
FieldByName("MEMOFIELD").AsString works fine on one machine but not a second.

The first machine runs Suse 12.3 64-bit, with FPC 2.6.2 [2013/03/17] for x86_64. My program work on this machine.

The second machine run Suse 13.1 64-bit wirh FPC 2.6.4 [2014/03/07] for x86_64. On this machine AsString seems to return the whole block including the 8 bytes of "control" info at the start of the memo file block, first first 4 being $FF $FF $80 $00, and the second 4 being what I can see is an offset to the end of the actual string.

I tried looking at the differences between the dbase code in the RTL but could not see anything that would explain the difference in behaviour.

Added to the Bug tracker as Issue 26332.

Thanks,
Dave Copeland.

Reply by email

Reinier Olislagers
to David Copeland
David Copeland wrote
Added to the Bug tracker as Issue 26332.

Hi Dave,

Although you wrote in the bug report that the attached zip contains test source code, it doesn't. Could you attach a simple (FPC) test program to the bug report that demonstrates the problem?

Thanks,
Reinier

Reply by email

David Copeland
to Reinier Olislagers

Oops, I have now uploaded the program source to the Bug tracker. Also reproduced here ...

program dbftest;
{$mode objfpc}{$H+}
uses
    {$IFDEF UNIX}{$IFDEF UseCThreads}
    cthreads,
    {$ENDIF}{$ENDIF}
    Classes, SysUtils, dbf, db;
    { you can add units after this }
var
    dbase: Tdbf;
    s: string;
    dbname: string;
    cwd: string;
    out_filename: string = 'test.csv';
    outfile: Text;
    header: boolean = false;
    buf: string;
    sep: string;
    rec_count: integer = 0;
    field_count: integer;
    fieldname: string;
    i, x: integer;
begin
    Assign(outfile,out_filename);
    Rewrite(outfile);
    buf := '';
    dbase := TDbf.Create(nil);
    GetDir(0,cwd);
    dbase.FilePathFull := cwd;
    dbase.TableName    := 'BOX78.dbf';
    dbase.ReadOnly     := true;
    dbase.Open;
    field_count := dbase.FieldCount;
    writeln('Table level is ', dbase.TableLevel, '. Number of fields is
', field_count);
    sep := '';
    for i := 0 to field_count - 1 do begin
        writeln(dbase.Fielddefs[i].Name, ', ', dbase.FieldDefs[i].DataType);
        buf := buf + sep + trim(dbase.Fielddefs[i].Name);
        sep := ',';
    end;
    if header then writeln(outfile,buf);
    while not dbase.EOF do begin
        inc(rec_count);
        buf := '';
        sep := '';
        for i := 0 to field_count - 1 do begin
            fieldname := trim(dbase.Fielddefs[i].Name);
            case dbase.FieldDefs[i].DataType of
                ftString, ftMemo:
                    buf := buf + sep + '"' +
trim(dbase.FieldByName(fieldname).AsString) + '"';
                ftInteger, ftSmallInt:
                    buf := buf + sep +
trim(dbase.FieldByName(fieldname).AsString);
            end;
            sep := ',';
        end;
        writeln(outfile,buf);
        dbase.Next;
    end;
    writeln(inttostr(rec_count) + ' records read.');
    dbase.Close;
    dbase.Destroy;
    Close(outfile);
end.

Dave.

Reinier Olislagers wrote 13 lines
On 12/06/2014 20:37, David Copeland wrote: > Added to the Bug tracker as Issue 26332. Hi Dave, Although you wrote in the bug report that the attached zip contains test source code, it doesn't. Could you attach a simple (FPC) test program to the bug report that demonstrates the problem? Thanks, Reinier _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

David Copeland
to Reinier Olislagers
Reinier Olislagers wrote 5 lines
Got some questions/remarks/workaround for you in the bug report... _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Hi Reinier,

I've read your notes and questions.

I have been told, second hand, that the application is DBase IV, but I will go to the source to confirm this, then report the results in the bug tracker, along with answers to the other questions.

Thanks,
Dave.

Reply by email