Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002

    Unanswered: Dbase IV Memo fields: Can't export

    I am trying to export data from some .dbf files I have received. I use a program called Data Junction which allows me to read the .dbf files and export them in any format I require.

    The problem I am having is exporting 2 memo fields from one of the .dbf files.

    At first glance they appear correct when looking at the source data, however scrolling down the file they begin to become corrupt. They become inconsistent, as though they cannot be read properly.

    Does anyone know of a utility which will allow me to view the contents of a .dbf file? Or know how the memo fields are structure which may assist me in comng up with a solution.

    Thanks in advance.

  2. #2
    Join Date
    Dec 2002

    Dbase Memo fields

    Memo fields are tough to untangle. The DBF table has 10 characters reserved for each memo field in each record with a unique identifier that dBase then uses internally to find your "memo" in the DBT. I sure wouldn't try to do that myself, as there is not much documentation for that.

    Depending on where you're trying to export to, you can always do it the long way. Since I have not worked with the program you're using to export nor the destination, my only suggestion is to try this alternative, though clunky it works fine with text. We will move the memo's text into character fields, but remember, dBase allows only up to 254 characters per character field. Here's a neat way to get around it.

    Make sure there is a unique field for each record in the source file.

    Then create a second "data" table to hold just the memo field contents:
    C_TABLE && name of the source table (optional if just one table)
    C_MFIELD && name of the memo field
    C_RECID && record ID or whatever uniquely identifies the record
    N_CNT && numeric field to hold the counter
    C_DATA && data from memo field (size is 50, 100 or up to 250)

    PROCEDURE memo2chr
    SELECT 1
    USE myfile && ORDER whatever
    SELECT 2
    USE memodata && this is work table described above
    SELECT 1
    SELECT 2
    DO copydata WITH "memofield1" && note: send memo field name
    DO copydata WITH "memofield2" && since data may be huge
    USE IN 1
    USE IN 2

    PROCEDURE copydata
    PARAMETER memoname
    PRIVATE xlen, x, loopcnt, xdata
    DO WHILE x<=xlen
    xdata=SUBSTR(myfile->&memoname,x,50) && set chunk size here
    * IF LEN(RTRIM(x_data))=0 && use the IF only to get rid of spaces?
    REPLACE c_table WITH ALIAS(1)
    REPLACE c_mfield WITH memoname
    REPLACE c_recid WITH myfile->uniquefld
    REPLACE n_cnt WITH loopcnt
    REPLACE c_data WITH x_data
    * ENDIF
    * now entire memo field has been copied in sections to char field

    Then do the reverse at the destination to put the data wherever you need it... if you have the know-how of course.

    (If you knew your memo fields never held long strings of text/data, you could also do this idea within the same table by creating however many character fields were necessary to do this.)

    This was the way one place I worked kept all their memo field data after their networks (MS Windows Servers) started having repeated problems with memo fields getting corrupted. Clunky, but you do what you have to do...
    Last edited by Mark Amanns; 12-13-02 at 13:20.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts