Moving to X# and the winner is...
Posted: Fri May 03, 2019 7:33 am
Hi, I've looked everywhere that I can think of logically for these questions, so I'll leave it here.
Take for example, this VO 2.8 code which I have poseted here before:
METHOD Start() CLASS App
LOCAL oServer as DbServer
local aDBF as array
Local cDir
cDir := WorkDir() + "Invoices"
DirMake(cDir)
cDir := WorkDir() + "Filters"
DirMake(cDir)
cDir := WorkDir() + "Original Reports"
DirMake(cDir)
request dbfcdx
RddSetDefault("DBFCDX")
Set Decimals to 2
// 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("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", 250, 0})
AAdd(aDBF, {"MapFile", "C", 250, 0})
DBCREATE("Details", aDBF, "DBFCDX")
oServer := DbServer{"DETAILS"}
oServer:CreateOrder("CLCode", "Details", "CLCode" )
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, 0)
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()
// Create Configuration File Database
aDBF := {}
AAdd(aDBF, {"FromEmail", "C", 100, 0})
AAdd(aDBF, {"TermDays", "N", 3, 0})
AAdd(aDBF, {"EOM", "N", 3, 0})
AAdd(aDBF, {"CLName", "C", 100, 0})
AAdd(aDBF, {"ABN", "C", 15, 0})
AAdd(aDBF, {"Add1", "C", 100, 0})
AAdd(aDBF, {"Add2", "C", 100, 0})
AAdd(aDBF, {"Suburb", "C", 50, 0})
AAdd(aDBF, {"State", "C", 3, 0})
AAdd(aDBF, {"Pcode", "C", 4, 0})
AAdd(aDBF, {"Phone1", "C", 20, 0})
AAdd(aDBF, {"Email", "C", 100, 0})
AAdd(aDBF, {"TandC", "M", 10, 0})
DBCREATE("BMConfig", aDBF, "DBFCDX")
FCopy("BMInvoice.rpt", cDir + "BMInvoice.rpt")
FCopy("Blank Invoice.rpt", cDir + "Blank Invoice.rpt")
FCopy("JobNumber.rpt", cDir + "JobNumber.rpt")
FCopy("JobList.rpt", cDir + "JobList.rpt")
FCopy("WorkSheet.rpt", cDir + "WorkSheet.rpt")
FCopy("Client Details.rpt", cDir + "Client Details.rpt")
self:Quit()
Return self
I cannot see anywhere how to recode that (or something giving the same result) using X#. Is is possible? If so, how please.
I don't expect you to rewrite the entire code, just add pointers where I'm going wrong. These are just some of the errors I'm getting on compiling:
error XS9003: Pre-processor: Include file not found: 'VOSystemLibrary.vh' 4,10 Start1.prg SdiApp1
error XS9003: Pre-processor: Include file not found: 'VOSystemClasses.vh' 5,10 Start1.prg SdiApp1
error XS9002: Parser: unexpected input '{#' 337,13 Start1.prg SdiApp1
error XS9002: Parser: unexpected input '}' 337,24 Start1.prg SdiApp1
error XS9002: Parser: mismatched input 'AS' 340,14 Start1.prg SdiApp1
error XS9002: Parser: unexpected input 'RETURN' 342,9 Start1.prg SdiApp1
error XS9002: Parser: mismatched input '(' expecting EOS 342,29 Start1.prg SdiApp1
Compilation failed (7 errors)
The Return error, I'm thinking is just a complier switch, and the first two are ok also.. Others I have had say that Arrays are not applicable in X# core, dbDServer namespace error etc.
Thanks again.
Take for example, this VO 2.8 code which I have poseted here before:
METHOD Start() CLASS App
LOCAL oServer as DbServer
local aDBF as array
Local cDir
cDir := WorkDir() + "Invoices"
DirMake(cDir)
cDir := WorkDir() + "Filters"
DirMake(cDir)
cDir := WorkDir() + "Original Reports"
DirMake(cDir)
request dbfcdx
RddSetDefault("DBFCDX")
Set Decimals to 2
// 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("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", 250, 0})
AAdd(aDBF, {"MapFile", "C", 250, 0})
DBCREATE("Details", aDBF, "DBFCDX")
oServer := DbServer{"DETAILS"}
oServer:CreateOrder("CLCode", "Details", "CLCode" )
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, 0)
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()
// Create Configuration File Database
aDBF := {}
AAdd(aDBF, {"FromEmail", "C", 100, 0})
AAdd(aDBF, {"TermDays", "N", 3, 0})
AAdd(aDBF, {"EOM", "N", 3, 0})
AAdd(aDBF, {"CLName", "C", 100, 0})
AAdd(aDBF, {"ABN", "C", 15, 0})
AAdd(aDBF, {"Add1", "C", 100, 0})
AAdd(aDBF, {"Add2", "C", 100, 0})
AAdd(aDBF, {"Suburb", "C", 50, 0})
AAdd(aDBF, {"State", "C", 3, 0})
AAdd(aDBF, {"Pcode", "C", 4, 0})
AAdd(aDBF, {"Phone1", "C", 20, 0})
AAdd(aDBF, {"Email", "C", 100, 0})
AAdd(aDBF, {"TandC", "M", 10, 0})
DBCREATE("BMConfig", aDBF, "DBFCDX")
FCopy("BMInvoice.rpt", cDir + "BMInvoice.rpt")
FCopy("Blank Invoice.rpt", cDir + "Blank Invoice.rpt")
FCopy("JobNumber.rpt", cDir + "JobNumber.rpt")
FCopy("JobList.rpt", cDir + "JobList.rpt")
FCopy("WorkSheet.rpt", cDir + "WorkSheet.rpt")
FCopy("Client Details.rpt", cDir + "Client Details.rpt")
self:Quit()
Return self
I cannot see anywhere how to recode that (or something giving the same result) using X#. Is is possible? If so, how please.
I don't expect you to rewrite the entire code, just add pointers where I'm going wrong. These are just some of the errors I'm getting on compiling:
error XS9003: Pre-processor: Include file not found: 'VOSystemLibrary.vh' 4,10 Start1.prg SdiApp1
error XS9003: Pre-processor: Include file not found: 'VOSystemClasses.vh' 5,10 Start1.prg SdiApp1
error XS9002: Parser: unexpected input '{#' 337,13 Start1.prg SdiApp1
error XS9002: Parser: unexpected input '}' 337,24 Start1.prg SdiApp1
error XS9002: Parser: mismatched input 'AS' 340,14 Start1.prg SdiApp1
error XS9002: Parser: unexpected input 'RETURN' 342,9 Start1.prg SdiApp1
error XS9002: Parser: mismatched input '(' expecting EOS 342,29 Start1.prg SdiApp1
Compilation failed (7 errors)
The Return error, I'm thinking is just a complier switch, and the first two are ok also.. Others I have had say that Arrays are not applicable in X# core, dbDServer namespace error etc.
Thanks again.