FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour It is possible to create a dbf table with two...
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 09: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

Marco Boschi
info@marcoboschi.it
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 09:40 AM

I think it is no possible

Best Regards, Saludos



Falconi Silvio
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 09:44 AM

Silvio,
take a look at

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

it seems that it is possible

bye

Marco Boschi
info@marcoboschi.it
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: It is possible to create a dbf table with two...
Posted: 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
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 12:34 PM
Marco, Silvio,

yes, it´s possible, see this sample

Code (fw): Select all Collapse
// 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
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 02: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

Marco Boschi
info@marcoboschi.it
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 02: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
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 02:56 PM

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

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 03: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.
Marco Boschi
info@marcoboschi.it
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 04: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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 04:21 PM

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

=====>

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

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 04:39 PM

Can any of you test the last sample?
Hello, see you tomorrow

Marco Boschi
info@marcoboschi.it
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 08: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: It is possible to create a dbf table with two...
Posted: Wed Mar 09, 2011 09:39 PM
It's a browse bug. Try this (many thanks to Andi):

Code (fw): Select all Collapse
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
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: It is possible to create a dbf table with two...
Posted: Thu Mar 10, 2011 07:24 AM

Many Thanks Enrico!

Marco Boschi
info@marcoboschi.it