Friday, September 21, 2007

A guide to discovering the Visual DataFlex Studio

A beginner’s guide to coding a custom database application in *Visual DataFlex
by Peter A Donovan/Applause Software/Boston.

*Visual DataFlex is a trademark of Data Access Worldwide of Miami.

Here’s a conceptual step-by-step methodology for creating your first Visual DataFlex application.
Visual DataFlex is a “transparent back end” database application studio where the same exact code runs on your choice of backend.
This overview assumes you will start with the native DataFlex backend as a starting point.
To encourage you to try the Visual DataFlex studio for a test drive using [freeware] the Personal DataFlex edition licensed for personal but not commercial use.
This is a full studio deploy with no restrictions other than mentioned above.
Compelling Reasons:
You can most likely produce a fundamentally solid application in ½ the time as your current studio.

First, let’s assume you have the studio downloaded from and you are running on a 30 day eval prior to getting a license.

If you fire up the Visual DataFlex Studio, you’ve got the “order entry” sample example workspace automatically loaded for you, and the current project is “Order.src”. From this point, you should hit [F5] and the “source code = src” will compile into an executable and run. Please check out the features of the running program. This, we will code ourselves in a new “SRC” project to see how it was done.

1. From the menu, choose File-New-Project-Windows Project, and you will get a dialog asking for the .EXE name. Please type “Test” and press ok.
2. For fun, just hit [F5] and compile an executable, which you will find is a perfect MDI [multiple dialog interface] container with no functionality BUT… the button bar, menu headers, and runtime are all done.
3. Back in the Studio, let’s create a data entry program or form if you will. Click File-New-View/Report-Data Entry View Wizard, and click Ok.
4. From the wizard, click “next” on the opening page.
5. For an object name, please enter “oSalesOrder” and accept the defaults for the next 2 windows and click “next”.
6. Next page: change the radio button please to select “create a header-detail entry view” and click “next”.
7. Now, the time has come to select the CHILD table for the data entry view, so highlight “OrderDtl” and click “next”.
8. For the “header” data table, we will select “Orderhea” and click “next”.
9. Now, we select the columns “fields” to show in the data entry HEADER section, and I recommend: Choose ALL the columns from the OrderHeader table EXCEPT the last one [last detail number] and click “next”.
10. Now, we select the columns “fields” to show in the child grid below the header, and I recommend: Choose ALL the columns [except for the FIRST : ordernumber] from the detail table and click “next”.
11. Next, you get to customize the labels for each of the forms if you like, but the default has already been programmed into the datadictionary, so simply change the radio button to “right” justify the labels, and click “next”, and “Finish”.
12. Press [F5] which auto-saves and compiles your SRC into a EXE and test!

You now have a running program [under the view menu] which actually saves sales orders and detail lines. Not the most appealing visually, but structurally sound.
You will find that there are entry methods associated with some database columns, and exit methods associated with some. You MUST find a parent table record in order to save, and you MUST fill in some required fields. There’s a snazzy lookup list [expandable] for each of the associated tables, and some columns automatically are instantiated as comboforms for you automatically. A couple of small modifications later and we are on the road to deploying this. [omitted].

This is just a sample of the power of Visual DataFlex, and a few words of explanation are required to answer questions that this may have raised.

* The datadictionary for each of the tables has been pre-coded for you in this sample example.
* The datadictionary for the parent tables adjusts automatically, knowing that it is used as a parent reference, to be “find required” in an excellent display of polymorphism. The same exact table behaves differently when it is the main table for data entry, i.e. no “find required”.
* The key fields/columns of each table cannot be changed: they are protected from change via a checkbox in the datadictionary.
* The labels for each column are configured in the datadictionary so they appear consistent throughout your application.
* The lookup lists, called selection lists are assigned to a table-column in the datadictionary so they automatically appear with a prompt button with no code.
* The Order Header TOTAL automatically adds and subtracts based on what you do with the lineitems: delete/save new/change.
* The Product on_hand total automatically adds and subtracts based on what you do with the lineitems: delete/save new/change.
* For a real LASTING impression of visual dataflex, please note the quantity onhand of a lineitem product, and then CHANGE the product in the lineitem without changing the quantity. * Then, choose the lookup, and you will see that the lineitem quantity has been moved back INTO inventory for the product you changed. Note: there are about 5 lines of code in the datadictionary that make this happen!
* Now, for real fun…, place the cursor in the header section on customer and choose DELETE from the button bar. Surprise, the customer is not deleted but the entire order and all of it’s lineitems are deleted. Repeat: place the cursor on the product code column of an existing lineitem and hit DELETE. The product is not deleted, but only the lineitem.

By this point, you may be ready to give the datadictionary a once-over!
From the Studio, select Tools-Database Builder. This utility creates the CLASS that each datadictionary object [in your entry form] is based on.
From the “Open Table” pulldown, select “Order Header” and browse thru the settings. It’s extremely impressive I think in the maturity of the product.

Ok, you want to give Visual DataFlex a shot, but where do you go for help?
The Visual DataFlex newsgroup: The url is: news://
Please introduce yourself as a new developer and we will welcome you with advice and support.

Thanks for giving Visual DataFlex a trial, and look forward to seeing you on the newsgroup!

Peter A Donovan of Boston, USA

No comments: