Hi Matt,
FoxProMatt_MattSlay wrote:
Once the release is publicly available, it would be nice to have a code sample (maybe a new blog post) that shows the exact lines of code that are required to open a DBF and loop over it to print or display a few of the fields the screen or in a simple dialog. Just a simple code example that VFP users can see the X# code and even copy-paste it onto a project and see it run.
With the public GA to be released soon, here is a bit of "DBFVFP" background.
First thing, one need to understand the pre-processor. In that context the following from the X# include folder in the file dbCmd.xh:
Code: Select all
#command USE => dbCloseArea()
#command USE <(db)> ;
[VIA <rdd>] ;
[ALIAS <a>] ;
[<new: NEW>] ;
[<ex: EXCLUSIVE>] ;
[<sh: SHARED>] ;
[<ro: READONLY>] ;
[INDEX <(index1)> [, <(indexn)>]] ;
;
=> dbUseArea( ;
<.new.>, <rdd>, <(db)>, <(a)>, ;
if(<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.> ;
) ;
;
[; dbSetIndex( <(index1)> )] ;
[; dbSetIndex( <(indexn)> )]
The trick to see how the command is translated into a function call is the optional VIA part. That allows us to tell the system what driver we want to use. There are a couple of surprises that this allows us to do using the Replaceable Database Driver (RDD) concept:
Code: Select all
USE "c:blahblah" VIA "DBFVFP"
USE "c:blahblah.csv" VIA "DELIM" FIELDS {{"Name", "C", 10, 0}, {"LastName", "C", 30, 0}} DELIMITER ","
There is also a function RddSetDefault("DBFVFP") that we can use at startup to set the default RDD if we want to omit the VIA clause.
Hope this is of interest to some.