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

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

Postby MarcoBoschi » Wed Mar 09, 2011 9:16 am

...or more fields with the same name?

The answer is Yes:

#include "Fivewin.ch"

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


Just an alert

Best regards

marco
User avatar
MarcoBoschi
 
Posts: 1028
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

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

Postby Silvio » Wed Mar 09, 2011 9:40 am

I think it is no possible
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

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

Postby MarcoBoschi » Wed Mar 09, 2011 9:44 am

Silvio,
take a look at

http://groups.google.com/group/comp.lan ... d7247170b#

it seems that it is possible

bye
User avatar
MarcoBoschi
 
Posts: 1028
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

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

Postby Silvio » Wed Mar 09, 2011 10:54 am

hiii...

but then how save the record ?

replace ctext to samename
replace ctext1to samename
replace ctext2 to samename

I think you'll save on the same field
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

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

Postby StefanHaupt » Wed Mar 09, 2011 12:34 pm

Marco, Silvio,

yes, it´s possible, see this sample

Code: Select all  Expand view
// The example shows how to create a new database from a
// structure definition array using the DBFCDX driver.
#include "Fivewin.ch"


   REQUEST DBFCDX

   PROCEDURE Main()
      LOCAL aStruct := { ;
               { "CHARACTER", "C", 25, 0 }, ;
               { "NUMERIC"  , "N",  8, 0 }, ;
               { "DOUBLE"   , "N",  8, 2 }, ;
               { "DATE"     , "D",  8, 0 }, ;
               { "LOGICAL"  , "L",  1, 0 }, ;
               { "MEMO"     , "M", 10, 0 }, ;
               { "MEMO"     , "M", 10, 0 }  ;
            }
      ? "Creating Database...."
      DbCreate( "testdbf", aStruct, "DBFCDX", .T., "MYALIAS" )
      MyAlias->(dbAppend())

      MyAlias->Memo := "Memofield 1"  // Insert text to Menmfield 1
      FieldPut (7, "Memofield 2")     // Insert text to Memofield 2

      Browse()

   RETURN
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

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

Postby MarcoBoschi » Wed Mar 09, 2011 2:11 pm

Please try this:

#include "Fivewin.ch"

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

Many thanks
marco
User avatar
MarcoBoschi
 
Posts: 1028
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

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

Postby Bayron » Wed Mar 09, 2011 2:43 pm

Hi all,

If the code to manipulate the introduction of data is bigger, and harder to remember what it was introducted where, I wonder what will be the use of having the same name in the fields???
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

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

Postby James Bott » Wed Mar 09, 2011 2:56 pm

I think Marco was pointing out that this is a bug.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

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

Postby MarcoBoschi » Wed Mar 09, 2011 3:59 pm

Stefan Please compile your sample without fivewin
Please remove this line and compile again

#include "Fivewin.ch" // REMOVE THIS LINE AND COMPILE AGAIN


REQUEST DBFCDX

PROCEDURE Main()
LOCAL aStruct := { ;
{ "CHARACTER", "C", 25, 0 }, ;
{ "NUMERIC" , "N", 8, 0 }, ;
{ "DOUBLE" , "N", 8, 2 }, ;
{ "DATE" , "D", 8, 0 }, ;
{ "LOGICAL" , "L", 1, 0 }, ;
{ "MEMO" , "M", 10, 0 }, ;
{ "MEMO" , "M", 10, 0 } ;
}
? "Creating Database...."
DbCreate( "testdbf", aStruct, "DBFCDX", .T., "MYALIAS" )
MyAlias->(dbAppend())

MyAlias->Memo := "Memofield 1" // Insert text to Menmfield 1
FieldPut (7, "Memofield 2") // Insert text to Memofield 2

Browse()

RETURN

I've tested and with fivewin works fine, without not.
User avatar
MarcoBoschi
 
Posts: 1028
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

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

Postby driessen » Wed Mar 09, 2011 4:03 pm

Marco,

I did the test and it works indeed.

But, fields with the same name in a DBF don't have any sence.

I browsed the result of your test. If I change the data in one field "SAMENAME", all the fields "SAMENAME" are changed.
So in fact there is only one field "SAMENAME".
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

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

Postby Bayron » Wed Mar 09, 2011 4:21 pm

Hi Driessen;
As James pointed up, Marco is reporting this issue as a bug....
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

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

Postby MarcoBoschi » Wed Mar 09, 2011 4:39 pm

Can any of you test the last sample?
Hello, see you tomorrow
User avatar
MarcoBoschi
 
Posts: 1028
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

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

Postby Enrico Maria Giordano » Wed Mar 09, 2011 8:55 pm

MarcoBoschi wrote:Please try this:


I just tried with Clipper 5.3b and found a similar behavior. Anyway, I will try to report it to the developers.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

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

Postby Enrico Maria Giordano » Wed Mar 09, 2011 9:39 pm

It's a browse bug. Try this (many thanks to Andi):

Code: Select all  Expand view
FUNCTION MAIN()

    DBCREATE( "MYTEST", { { "TEST", "C", 35, 0 },;
                          { "TEST", "C", 35, 0 } } )

    USE MYTEST

    APPEND BLANK

    FIELDPUT( 1, "Test 1" )
    FIELDPUT( 2, "Test 2" )

    ? FIELDGET( 1 )
    ? FIELDGET( 2 )

    CLOSE

    INKEY( 0 )

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

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

Postby MarcoBoschi » Thu Mar 10, 2011 7:24 am

Many Thanks Enrico!
User avatar
MarcoBoschi
 
Posts: 1028
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 134 guests