From: Kevin on
Hi all,

The function CreateTransactionsDB is based on code created by the DBF
Utility in VOPP. I have modified it so that it can create the DBF in a
directory specified when the function is called, as demonstrated in the
Start method below.

This works fine, except the Index does not open automatically when the
DBF is opened. Can anyone explain what is wrong?

The RDDInfo call at the start of the function returns NIL. I am probably
missing something simple but I cannot see what it is.

Thanks in advance.

Kevin


method Start() class App
local oMainWindow as StandardShellWindow
RddSetDefault("DBFCCDX")

//self:Initialize()

oMainWindow := StandardShellWindow{self}
oMainWindow:Show(SHOWCENTERED)

CreateTransactionsDB( "C:\VOProjects\Membership\database\")

self:Exec()
return nil

FUNCTION CreateTransactionsDB( sDir as string) as logic
LOCAL aStruct as ARRAY
LOCAL lAutoOpen as USUAL
LOCAL cBaseName as STRING
LOCAL lSuccess as LOGIC

FIELD TRAN_ID, TRAN_DATE, TRAN_REF, DETAIL, AMOUNT

// Prevent any production index being opened automatically
// this will let us delete it (works with DBFCDX, not ADBFCDX)
lAutoOpen := RDDINFO(_SET_AUTOOPEN,FALSE)

aStruct := { ;
{ "TRAN_ID", "C", 10, 0 }, ;
{ "TRAN_DATE", "D", 8, 0 }, ;
{ "TRAN_REF", "C", 15, 0 }, ;
{ "DETAIL", "C", 30, 0 }, ;
{ "AMOUNT", "N", 12, 2 } ;
}

cBaseName := "TRANSACTIONS"

IF ( lSuccess := DBCREATE(sDir + cBaseName,aStruct,"DBFCDX",,,,,) )

IF ( lSuccess := DBUSEAREA(.T.,"DBFCDX",sDir +
cBaseName,__UniqueAlias(cBaseName),FALSE,,,) )

// Note: if you have indexes of other names you may
// want to put the deletion code here
IF File(cBaseName+DbOrderInfo(DBOI_INDEXEXT))
FErase(FPathName())
ENDIF

lSuccess := iif(lSuccess,DBSETORDERCONDITION(,,,,,,,,,,.F.),lSuccess)
lSuccess := iif(lSuccess,DBCREATEORDER("TRAN_D", sDir + "TRANSACT",
[TRAN_ID], {|| TRAN_ID }, .T.),lSuccess)

DBCLOSEAREA()

ENDIF

ENDIF

RDDINFO(_SET_AUTOOPEN,lAutoOpen)

RETURN lSuccess

From: Jamal on
Kevin,

In your app start method, add:

VODBRddSetDefault("DBFCDX")
RDDINFO(_SET_AUTOOPEN, TRUE)
RDDINFO(_SET_AUTOORDER, 1)
RDDINFO(_SET_MEMOBLOCKSIZE, 64)

Jamal

"Kevin" <kdmurphy(a)eircom.net> wrote in message
news:xTmvn.846$I8.399(a)news.indigo.ie...
> Hi all,
>
> The function CreateTransactionsDB is based on code created by the DBF
> Utility in VOPP. I have modified it so that it can create the DBF in a
> directory specified when the function is called, as demonstrated in the
> Start method below.
>
> This works fine, except the Index does not open automatically when the DBF
> is opened. Can anyone explain what is wrong?
>
> The RDDInfo call at the start of the function returns NIL. I am probably
> missing something simple but I cannot see what it is.
>
> Thanks in advance.
>
> Kevin
>
>
> method Start() class App
> local oMainWindow as StandardShellWindow
> RddSetDefault("DBFCCDX")
>
> //self:Initialize()
>
> oMainWindow := StandardShellWindow{self}
> oMainWindow:Show(SHOWCENTERED)
>
> CreateTransactionsDB( "C:\VOProjects\Membership\database\")
>
> self:Exec()
> return nil
>
> FUNCTION CreateTransactionsDB( sDir as string) as logic
> LOCAL aStruct as ARRAY
> LOCAL lAutoOpen as USUAL
> LOCAL cBaseName as STRING
> LOCAL lSuccess as LOGIC
>
> FIELD TRAN_ID, TRAN_DATE, TRAN_REF, DETAIL, AMOUNT
>
> // Prevent any production index being opened automatically
> // this will let us delete it (works with DBFCDX, not ADBFCDX)
> lAutoOpen := RDDINFO(_SET_AUTOOPEN,FALSE)
>
> aStruct := { ;
> { "TRAN_ID", "C", 10, 0 }, ;
> { "TRAN_DATE", "D", 8, 0 }, ;
> { "TRAN_REF", "C", 15, 0 }, ;
> { "DETAIL", "C", 30, 0 }, ;
> { "AMOUNT", "N", 12, 2 } ;
> }
>
> cBaseName := "TRANSACTIONS"
>
> IF ( lSuccess := DBCREATE(sDir + cBaseName,aStruct,"DBFCDX",,,,,) )
>
> IF ( lSuccess := DBUSEAREA(.T.,"DBFCDX",sDir +
> cBaseName,__UniqueAlias(cBaseName),FALSE,,,) )
>
> // Note: if you have indexes of other names you may
> // want to put the deletion code here
> IF File(cBaseName+DbOrderInfo(DBOI_INDEXEXT))
> FErase(FPathName())
> ENDIF
>
> lSuccess := iif(lSuccess,DBSETORDERCONDITION(,,,,,,,,,,.F.),lSuccess)
> lSuccess := iif(lSuccess,DBCREATEORDER("TRAN_D", sDir + "TRANSACT",
> [TRAN_ID], {|| TRAN_ID }, .T.),lSuccess)
>
> DBCLOSEAREA()
>
> ENDIF
>
> ENDIF
>
> RDDINFO(_SET_AUTOOPEN,lAutoOpen)
>
> RETURN lSuccess
>
From: Stephen Quinn on
Kevin

> This works fine, except the Index does not open automatically when the DBF
> is opened. Can anyone explain what is wrong?

> cBaseName := "TRANSACTIONS"
> lSuccess := iif(lSuccess,DBCREATEORDER("TRAN_D", sDir + "TRANSACT",
> [TRAN_ID], {|| TRAN_ID }, .T.),lSuccess)

Your index doesn't have the same name as the DBF (which you MUST have for
AutoOpen to work)
- either TRANSACT or TRANSACTIONS
- you decide which one to change.


CYA
Steve


From: Kevin on
Jamal,

Thanks for the suggestion but it did not work.

If I create the table using the DBServer Editor the index is opened
automatically without any extra lines. But when created using this code
it does not work.

Kevin



"Jamal" <vodotnet_nospam(a)yahoo.com> wrote in message
news:hpl0jv$g35$1(a)news.eternal-september.org:

> Kevin,
>
> In your app start method, add:
>
> VODBRddSetDefault("DBFCDX")
> RDDINFO(_SET_AUTOOPEN, TRUE)
> RDDINFO(_SET_AUTOORDER, 1)
> RDDINFO(_SET_MEMOBLOCKSIZE, 64)
>
> Jamal
>
> "Kevin" <kdmurphy(a)eircom.net> wrote in message
> news:xTmvn.846$I8.399(a)news.indigo.ie...
> > Hi all,
> >
> > The function CreateTransactionsDB is based on code created by the DBF
> > Utility in VOPP. I have modified it so that it can create the DBF in a
> > directory specified when the function is called, as demonstrated in the
> > Start method below.
> >
> > This works fine, except the Index does not open automatically when the DBF
> > is opened. Can anyone explain what is wrong?
> >
> > The RDDInfo call at the start of the function returns NIL. I am probably
> > missing something simple but I cannot see what it is.
> >
> > Thanks in advance.
> >
> > Kevin
> >
> >
> > method Start() class App
> > local oMainWindow as StandardShellWindow
> > RddSetDefault("DBFCCDX")
> >
> > //self:Initialize()
> >
> > oMainWindow := StandardShellWindow{self}
> > oMainWindow:Show(SHOWCENTERED)
> >
> > CreateTransactionsDB( "C:\VOProjects\Membership\database\")
> >
> > self:Exec()
> > return nil
> >
> > FUNCTION CreateTransactionsDB( sDir as string) as logic
> > LOCAL aStruct as ARRAY
> > LOCAL lAutoOpen as USUAL
> > LOCAL cBaseName as STRING
> > LOCAL lSuccess as LOGIC
> >
> > FIELD TRAN_ID, TRAN_DATE, TRAN_REF, DETAIL, AMOUNT
> >
> > // Prevent any production index being opened automatically
> > // this will let us delete it (works with DBFCDX, not ADBFCDX)
> > lAutoOpen := RDDINFO(_SET_AUTOOPEN,FALSE)
> >
> > aStruct := { ;
> > { "TRAN_ID", "C", 10, 0 }, ;
> > { "TRAN_DATE", "D", 8, 0 }, ;
> > { "TRAN_REF", "C", 15, 0 }, ;
> > { "DETAIL", "C", 30, 0 }, ;
> > { "AMOUNT", "N", 12, 2 } ;
> > }
> >
> > cBaseName := "TRANSACTIONS"
> >
> > IF ( lSuccess := DBCREATE(sDir + cBaseName,aStruct,"DBFCDX",,,,,) )
> >
> > IF ( lSuccess := DBUSEAREA(.T.,"DBFCDX",sDir +
> > cBaseName,__UniqueAlias(cBaseName),FALSE,,,) )
> >
> > // Note: if you have indexes of other names you may
> > // want to put the deletion code here
> > IF File(cBaseName+DbOrderInfo(DBOI_INDEXEXT))
> > FErase(FPathName())
> > ENDIF
> >
> > lSuccess := iif(lSuccess,DBSETORDERCONDITION(,,,,,,,,,,.F.),lSuccess)
> > lSuccess := iif(lSuccess,DBCREATEORDER("TRAN_D", sDir + "TRANSACT",
> > [TRAN_ID], {|| TRAN_ID }, .T.),lSuccess)
> >
> > DBCLOSEAREA()
> >
> > ENDIF
> >
> > ENDIF
> >
> > RDDINFO(_SET_AUTOOPEN,lAutoOpen)
> >
> > RETURN lSuccess
> >

From: Kevin on
Stephen,

Thanks for that. That solved it alright.

If that is in the help file I missed it. I certainly missed the fact
that the code from VOPP had truncated the index file name.

Kevin



"Stephen Quinn" <stevejqNO(a)bigpondSPAM.net.au> wrote in message
news:ZJnvn.18132$pv.10016(a)news-server.bigpond.net.au:

> Kevin
>
> > This works fine, except the Index does not open automatically when the DBF
> > is opened. Can anyone explain what is wrong?
>
> > cBaseName := "TRANSACTIONS"
> > lSuccess := iif(lSuccess,DBCREATEORDER("TRAN_D", sDir + "TRANSACT",
> > [TRAN_ID], {|| TRAN_ID }, .T.),lSuccess)
>
> Your index doesn't have the same name as the DBF (which you MUST have for
> AutoOpen to work)
> - either TRANSACT or TRANSACTIONS
> - you decide which one to change.
>
>
> CYA
> Steve

 |  Next  |  Last
Pages: 1 2
Prev: WebService
Next: Importing and Exporting to Excel