xsharp.eu • Here's a tricky one... or not... :
Page 1 of 1

Here's a tricky one... or not... :

Posted: Thu Apr 25, 2019 6:25 am
by Anonymous
What am I doing wrong here please? This is the ENTIRE App. It's sole purpose in life is to create the folders, databases and CDX files required by my main app. Two CDX files are created perfectly - Clients.cdx and JobNo.cdx. Details.CDX just will not generate, and I cannot see why. I've changed the lengths of the fields InvFile and MapFile to 240 as I read somewhere anything over that causes problems (they were both 255 at the start, I've also tried 150 length for both) I've even tried commenting out the references to both those fields, yet the Index is still not being generated. The last database - Rates - as you can see uses no index. It is just that one index for the Details database. Any ideas at all please.All the databases are generated perfectly if that helps at all.

Here's the entire thing. It's a straight forward Terminal App.

FUNCTION Start()
LOCAL oServer
local aDBF as Array
Local cWorkDir
request dbfcdx
RddSetDefault("DBFCDX")
SetExclusive(true)
Set Decimals to 2
cWorkDir := WorkDir()
DirMake(cWorkDir + "Invoices")
DirMake(cWorkDir + "Db")
DirChange(cWorkDir + "Db")
SetDefault(cWorkDir + "Db")

// Create Client Database and Indexes
aDBF := {}
AAdd(aDBF, {"ClCode", "C", 10, 0})
AAdd(aDBF, {"ClName", "C", 100, 0})
AAdd(aDBF, {"ClAdd1", "C", 100, 0})
AAdd(aDBF, {"ClAdd2", "C", 100, 0})
AAdd(aDBF, {"ClState", "C", 3, 0})
AAdd(aDBF, {"ClSuburb", "C", 50, 0})
AAdd(aDBF, {"ClPhone", "C", 10, 0})
AAdd(aDBF, {"ClPcode", "C", 4, 0})
AAdd(aDBF, {"ClABN", "C", 20, 0})
AAdd(aDBF, {"ClEmail", "C", 100, 0})
AAdd(aDBF, {"ClComments", "M", 10, 0})
DBCREATE("CLIENT", aDBF, "DBFCDX")
oServer := DbServer{"Client"}
oServer:CreateOrder("CLCode", "Client","CLCode",,.T.)
oServer:CreateOrder("CLName", "Client", "ClName")
oServer:CreateOrder("ClState", "Client", "ClState")
oServer:CreateOrder("CLCodeName", "Client", "AllTrim(CLIENT->ClCode) + space(1) + Alltrim(CLIENT->ClName)" )
oServer:CreateOrder("CLPcode", "Client", "ClPCode")
oServer:Commit()
oServer:Close()


//Create Details Database and Indexes
aDBF := {}
AAdd(aDBF, {"ClCode", "C", 10, 0})
AAdd(aDBF, {"ClName", "C", 100, 0})
AAdd(aDBF, {"Dname", "C", 50, 0})
AAdd(aDBF, {"JobDate", "D", 10, 0})
AAdd(aDBF, {"JobFin", "L", 1, 0})
AAdd(aDBF, {"JobTime", "C", 10, 0})
AAdd(aDBF, {"JobDetails", "M", 10, 0})
AAdd(aDBF, {"NPC", "M", 10, 0})
AAdd(aDBF, {"JobNumber", "C", 5, 0})
AAdd(aDBF, {"PONumber", "C", 15, 0})
AAdd(aDBF, {"Rate", "N", 10, 2})
AAdd(aDBF, {"Units", "N", 10, 2})
AAdd(aDBF, {"RateType", "C", 15, 0})
AAdd(aDBF, {"Subby", "C", 50, 0})
AAdd(aDBF, {"Rego", "C", 50, 0})
AAdd(aDBF, {"Invoiced", "L", 1, 0})
AAdd(aDBF, {"InvFile", "C", 240, 0})
AAdd(aDBF, {"MapFile", "C", 240, 0})
DBCREATE("Details", aDBF, "DBFCDX")
oServer := DbServer{"DETAILS"}
oServer:CreateOrder("CLCode", "Details", "CLCode" )
oServer:CreateOrder("DName", "Details", "DName",, .T.)
oServer:CreateOrder("JobDate", "Details", "JobDate")
oServer:CreateOrder("JobFin", "Details", "JobFin")
oServer:CreateOrder("JobNumber", "Details", "JobNumber")
oServer:CreateOrder("PONumber", "Details", "PONumber",, .T.)
oServer:CreateOrder("Subby", "Details", "Subby",, .T.)
oServer:CreateOrder("Rego", "Details", "Rego")
oServer:CreateOrder("Invoiced", "Details", "Invoiced")
oServer:CreateOrder("InvFile", "Details", "InvFile")
oServer:CreateOrder("MapFile", "Details", "MapFile")
oServer:Commit()
oServer:Close()


//Create JobNumber Database
aDBF := {}
AAdd(aDBF, {"JobNumber", "N", 5, 0})
DBCREATE("JobNo", aDBF, "dbfcdx")
oServer := DbServer{"JobNo"}
oServer:CreateOrder("JobNumber", "JobNo","JobNumber")
oServer:APPEND()
oServer:FIELDPUT(#JobNumber, 1)
oServer:Commit()
oServer:Close()


// Create Rates Database and Indexes
aDBF := {}
AAdd(aDBF, {"RateType", "C", 10, 0})
DBCREATE("Rates", aDBF, "DBFCDX")
oServer := DbServer{"RATES"}
oServer:APPEND()
oServer:FIELDPUT(#RateType, "Each")
oServer:APPEND()
oServer:FIELDPUT(#RateType, "Hourly")
oServer:APPEND()
oServer:FIELDPUT(#RateType, "Quoted")
oServer:APPEND()
oServer:FIELDPUT(#RateType, "Zone")
oServer:Commit()
oServer:Close()


Return nil

Here's a tricky one... or not... :

Posted: Thu Apr 25, 2019 7:02 am
by lumberjack
Hi Jeff,
BiggyRat wrote:What am I doing wrong here please? Details.CDX just will not generate, and I cannot see why.
Any ideas at all please.All the databases are generated perfectly if that helps at all.

Code: Select all

FUNCTION Start()
...
   oServer:CreateOrder("JobDate", "Details", "DtoS(JobDate)") // Can you change the logic to change this to String index?
...
Return nil

Here's a tricky one... or not... :

Posted: Thu Apr 25, 2019 7:09 am
by BiggyRat
Thanks Johan, just tried that now, no difference...

Here's a tricky one... or not... :

Posted: Thu Apr 25, 2019 7:21 am
by lumberjack
BiggyRat wrote:Thanks Johan, just tried that now, no difference...
Jeff, can you comment out all the createorders and add them one by one to identify which order causes the trouble?

Here's a tricky one... or not... :

Posted: Thu Apr 25, 2019 7:49 am
by BiggyRat
Just completed doing that Johan..... the same result. No errors evident anywhere

Here's a tricky one... or not... :

Posted: Thu Apr 25, 2019 7:55 am
by FFF
Jeff,
on Win 8.1/64 German, using Vo2838b, put your code in a terminal app, added Rddlib, compiled an run.
This is the result
dbf.PNG
dbf.PNG (4.37 KiB) Viewed 304 times
Karl

Here's a tricky one... or not... :

Posted: Thu Apr 25, 2019 8:30 am
by BiggyRat
Yep. You're correct Karl. Seems it was caused by a Windows Protection System corruption. sfc /scannow fixed it.

Thanks very much for you help Johan and Karl