Thanks for sharing - for more understanding below is what I am using for code any comments about the coding below
OpenClient()
Function OpenClient()
local aFields := {}
SET OPENERROR OFF // don't display RTE on open failure
if !file("gbclient.dbf") // database available?
aadd(aFields,{'cat ', 'C', 4,0})
aadd(aFields,{'cust_no ', 'C', 6,0})
aadd(aFields,{'cust_name ', 'C', 50,0})
aadd(aFields,{'cust_cat ', 'C', 4,0})
aadd(aFields,{'geocode ', 'C', 7,0})
aadd(aFields,{'adress1 ', 'C', 30,0})
aadd(aFields,{'adress2 ', 'C', 30,0})
aadd(aFields,{'tel ', 'C', 17,0})
aadd(aFields,{'incharge ', 'C', 40,0})
aadd(aFields,{'baldate ', 'D', 8,0})
aadd(aFields,{'balancedue', 'N', 12,2})
aadd(aFields,{'balance_us', 'N', 12,2})
aadd(aFields,{'dbal_us ', 'D', 8,0})
aadd(aFields,{'date_new ', 'D', 8,0})
aadd(aFields,{'stat ', 'C', 1,0})
aadd(aFields,{'grp ', 'C', 1,0})
aadd(aFields,{'last_inv ', 'C', 8,0})
aadd(aFields,{'inv_value ', 'N', 11,2})
aadd(aFields,{'inv_date ', 'D', 8,0})
aadd(aFields,{'email ', 'C', 40,0})
aadd(aFields,{'comp ', 'C', 1,0})
aadd(aFields,{'cred_type ', 'C', 1,0})
aadd(aFields,{'cred_lim ', 'N', 11,2})
aadd(aFields,{'charges ', 'N', 9,2})
aadd(aFields,{'init_bal ', 'N', 11,2})
aadd(aFields,{'init_date ', 'D', 8,0})
aadd(aFields,{'init_balus', 'N', 11,2})
aadd(aFields,{'init_dateu', 'D', 8,0})
aadd(aFields,{'lastpayh ', 'N', 11,2})
aadd(aFields,{'lastpayh_d', 'D', 8,0})
aadd(aFields,{'lastpayus ', 'N', 11,2})
aadd(aFields,{'lastpayusd', 'D', 8,0})
aadd(aFields,{'vendeur ', 'C', 3,0})
aadd(aFields,{'avanceg ', 'N', 11,2})
aadd(aFields,{'avanceu ', 'N', 11,2})
aadd(aFields,{'adeposerg ', 'N', 11,2})
aadd(aFields,{'adeposeru ', 'N', 11,2})
aadd(aFields,{'nif ', 'C', 24,0})
DbCreate("gbclient", aFields) // create new database
use gbclient SHARED new alias clients
else
nFOpen := myDbfCheckOpen("clients")
if nFOpen = 0
// if not already open - open it
use gbclient SHARED new alias clients
else
// database already open
// select it in the working area to use it
endif
ENDIF
select clients
// check if all index are ok
if INDEXCHECK(1) > 0 .or. INDEXCHECK(2) > 0 .or. ;
!file("gbclien1.idx") .or. ;
!file("gbclien2.idx") .or. ;
!file("gbclien3.idx") .or. ;
!file("gbclien4.idx")
select clients
index on cust_no to gbclien1 //
index on cust_name to gbclien2
index on geocode to gbclien3
index on cust_cat to gbclien4
endif
if neterr()
alert("could not open 'categ?.idx', check permission")
my_use ("clients",, .T., .F.) // USE..EXCLUSIVE
endif
SET INDEX TO gbclien1,gbclien2,gbclien3,gbclien4
GO TOP // go to first logical record
return