Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

It is possible to create a dbf table with two...

19 views
Skip to first unread message

Marco Boschi

unread,
Mar 9, 2011, 4:15:55 AM3/9/11
to
...or more fields with the same name?

The answer is Yes:

REQUEST DBFCDX

FUNCTION MAIN()

LOCAL aStru1 := { }
LOCAL aStru2 := { }

AADD( aStru1 , { "FIRST" , "C" , 20 , 0 } )
AADD( aStru1 , { "LAST" , "C" , 20 , 0 } )

DbCreate( "OK" , aStru1 , "DBFCDX" )

AADD( aStru1 , { "FIRST" , "C" , 20 , 0 } )
AADD( aStru1 , { "LAST" , "C" , 20 , 0 } )
AADD( aStru1 , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru1 , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru1 , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru1 , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru1 , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru1 , { "SAMENAME" , "C" , 20 , 0 } )

DbCreate( "NOTOK" , aStru1 , "DBFCDX" )

RETURN NIL

Only an alert

Best regards

marco

Ella Stern

unread,
Mar 9, 2011, 4:33:59 AM3/9/11
to
Hello,

On Mar 9, 11:15 am, Marco Boschi <i...@marcoboschi.it> wrote:
> ...or more fields with the same name?
>
> The answer is Yes:
>

This is a standard feature of dBase files - it's a common situation,
when setting two tables is relation and forgetting to use aliases for
them.
The first occurence of the field is accessible by name.

In case the two fields are in the same table, you can use FCount(),
FieldGet(), FieldPut()... to access the fields.

In case of ADS tables all funcky characters are accepted as field
names ( including the SPACE ) and in such case using the Field...
functions are the only way to go.


Ella

Marco Boschi

unread,
Mar 9, 2011, 4:43:20 AM3/9/11
to

For example DBU.EXE does not allow to create fields with the same name

Thank you
Marco

Enrico Maria Giordano

unread,
Mar 9, 2011, 5:38:21 AM3/9/11
to
> ...or more fields with the same name?
>
> The answer is Yes:

I just tried your sample with Clipper 5.3b and it worked fine.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic


Enrico Maria Giordano

unread,
Mar 9, 2011, 5:39:42 AM3/9/11
to
> For example DBU.EXE does not allow to create fields with the same name

This is a feature of DBU.EXE. RDD *does* allow to create fields with the
same name.

Marco Boschi

unread,
Mar 9, 2011, 9:08:23 AM3/9/11
to
ok ok i just an alert
There is non sense in that.
Field name is just to access information of n field.
Two fields with same name is only confusion

It seems to be a primordial bug...unsolved.

However just knowing.

I'm scared this morning when I open a dbf table created by code with
two identical field.

I just mand this test


REQUEST DBFCDX

FUNCTION MAIN()

LOCAL aStru := { }

AADD( aStru , { "FIRST" , "C" , 20 , 0 } )
AADD( aStru , { "LAST" , "C" , 20 , 0 } )
AADD( aStru , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru , { "SAMENAME" , "C" , 20 , 0 } )
AADD( aStru , { "SAMENAME" , "C" , 20 , 0 } )

DbCreate( "NOTOK" , aStru , "DBFCDX" )

USE NOTOK
APPEND BLANK
REPLACE field->first WITH "test 1"
REPLACE field->samename WITH "replace samename"

APPEND BLANK
REPLACE field->first WITH "test 2"
fieldput( 5 , "FIELDPUT 5" )
fieldput( 6 , "FIELDPUT 6" )

APPEND BLANK
REPLACE field->first WITH "test 3"
fieldput( 5 , "FIELDPUT 5" )

APPEND BLANK
REPLACE field->first WITH "test 4"
fieldput( 6 , "FIELDPUT 6" )

APPEND BLANK
REPLACE field->first WITH "test 5"
fieldput( 3 , "FIELDPUT 3" )
RETURN NIL

the result shows something wrong

dlzc

unread,
Mar 9, 2011, 2:23:16 PM3/9/11
to
Dear Marco Boschi:

On Mar 9, 7:08 am, Marco Boschi <i...@marcoboschi.it> wrote:
> ok ok i just an alert
> There is non sense in that.
> Field name is just to access information of n field.
> Two fields with same name is only confusion
>
> It seems to be a primordial bug...unsolved.

What would you want the RDD to do on:
- creating a new file, with duplicate field names (error out?)
- opening a file with duplicate field names
- appending from a file with duplicate field names
- copying to a file, when the source has duplicate field names?

Yes, it is an old problem, as an internet search shows. Lots of DBF
access engines (not just Clipper / xHarbour) have had to handle it
over the years...

But then so is only having 10 character field names...

David A. Smith

Enrico Maria Giordano

unread,
Mar 9, 2011, 4:34:32 PM3/9/11
to
As Andi pointed out in the developers list, it is a browse bug, not a DBF
bug. If you read from the fields using fieldget() then you will get the
correct values.

Marco Boschi

unread,
Mar 10, 2011, 4:46:53 AM3/10/11
to
On 9 Mar, 22:34, "Enrico Maria Giordano"

Thanks to all

0 new messages