News Letter - March
This update expands the ASP.NET abilities started in the November Update. With the new functionality Visual FoxPro is now the best language for dealing with Data in ASP.NET
These are the major improvements
- ASP.NET. Significantly improved functionality including new Web Site project type, Ajax funcitonality for your WebPages, JSON WebServices and general WebServices.
- A new Simple Page Editor, let you code WebPages inside Visual FoxPro and then it exports them to ASPX pages for .NET. You have WysIWyg, Simple TagCompletion and Syntax highlighting. And of course all this inside is Visual FoxPro code.
- Multithreading support even for local variables. The TableLayer64 and the runtime has been improved to deal with Multithreaded code. This is very important for ASP.NET apps that are multithreaded in nature.
- Database Support several new commands related to Databases are available.
- Automatic ORM from Tables to Objects. Now we compile your Databases and Tables to .NET and enable several exciting scenarios. Including Compile time checking that your database dealing code is ok.
- CALCULATE and related functions implemented and now you can define your own aggregatable functions.
- SCATTER / GAHER also implemented
- Run "!" button in the .NET Extender Toolbar give you one click access to run your prg under .NET. This is simply easier than the way in .NET things are done.
- SQL Passthrough improved with the ability to call stored procedures returning RecordSets and tested with SQL Server, PostgreSQL, Oracle 8i and 10g (thanks to D.P.) and MySQL 5.x (thanks to J.D.)
- More commands and functions.
- Several new samples and walkthroughs for the new funcitonality.
ASP.NET - the Foxpro Way
This updates makes Web Programming with FoxPro amazingly simple and powerful. Things that in C# and VB are too hard to do, specially the related to Data Access and Data Binding, in VFP are so easy and so fast, that you have to try it to believe it. We are taking the Visual Foxpro Way and bringing it to the Web.
FoxServer
This sample shipped with source code is used to run your ASP.NET WebSites under FoxPro. Just click the Run button in the Compile Project form and it will start listening. By the way the Server runs in a separated thread so you can stop it clicking the Stop button in the Main form which of course is a Visual FoxPro form compiled to .NET. Check this sample to see how to start different threads in .NET
To look at the WebPages on your project just type: http://localhost:8080/MyWebPage.aspx or http://localhost:8080/MyWebPage.asmx in your favorite browser.
VFPPage
This class shipped with source code in ASP.NET.Demo project, gives you Data Binding the VFP Way.
So You want to bind your textbox, listbox or other control to VFPData? Just set the property VFPControlSource = "MyAlias.MyField" and all is automatically wired to your data.
This VFPPage is also a Sessioned class like Form or Session. This is a new feature in the compiler that let you to make any class a Sessioned class, this is capable of starting a new DataSession like the Form and Session classes do when DataSession = 2 (private).
There is nothing in .NET World giving you that kind of power. Check the online sample here for a demo, see below for an AJAX version.
New Project type in the Compile Project form
In addition to supporting Console Exes, DLL Assemblies, Winforms Exes now we support WebSite. Choosing this Project Type automatically adds references to system.web.dll, system.web.services.dll (web services), system.web.extensions.dll (ASP.NET Ajax) and ASP.NET.Demo.dll the assembly with VFPPage.
Also it creates two folders BIN and APP_Data to follow the usual layout for WebSites and moves the output to the BIN folder as ASP.NET expects it.
Web Tab in the compile project form
This new tab gives you access to the Create WebService and Create WebPage buttons that creates WebForms and WebServices.
You can choose if you want to enable Ajax - JSON functionality. If you mark that checkbox your WebPage / WebService will be AJAX ready and for Browser Interaction will support JSON in addition to standard XML WebServices.
Visual FoxPro meets AJAX
By default your Websites are enabled for Ajax and you can have non Ajax and Ajax pages mixed in the same WebSite.
When you mark the checkbox Enable AJAX - JSON when creating a new WebPage or WebService you gain automatically AJAX functionality. This allows your WebPage to be updated without a Server PostBack, increasing the speed, responsiveness and making your Customers happy.
Contrast the Non Ajax Version with the Ajax Version, the latter Feels Snappier, more responsive and using our TableLayer64 amazingly fast, looks like if it was a local page but in fact it is a remote page located thousands of miles away from you.
To make easier the testing and deploying we are using AJAX ASP.NET based in the Mono assemblies. You can of course use the Microsoft Assemblies shipped with the .NET Framework 3.50, but in that case you will need more work to make it work as installing both in the Server and in your machine.
And speaking of WebServices, you can invoke your WebServices using JSON as the wire format. this is useful if your WebService will be called from the Browser because JSON is a lot faster that using XML through SOAP.
Check here for a simple page calling the MySampleWebService.prg. Look at the source of the page, it is a simple HTML Page talking directly to your WebService using JavaScript, nothing more in the Client Side. This opens your Apps to the wide world of script libraries out there than now can bind and query to your apps enabling amazing interactions.
And look here for a ListBox with AJAX functionality, when you select a Category it displays the related information, to do that it calls to the server to gather the information. Don't be fooled by its speed the data for every category resides in the server.
All these samples are in the FoxWeb3.pjx project file located in the ProjectSamples directory, and look at the code it is just FoxPro code.
Simple Page Editor
A simple WysiWyg Editor for HTML is included. This editor allows to design Web Pages for ASP.NET, there is syntax highlighting, tag completion and extensions to put HTML elements and have them converted to ASP.NET tags when saving the document.
To .convert a HTML to a different ASP.NET tag just set the attribute aspTag="asp:SomeTag" as done in the MyFirstPage-ajax.html where there is a DIV tag holding aspTag="asp:UpdatePanel" that will be exported to an Ajax Update Panel.
Database support and database related commands
- GATHER, SCATTER implemented See the sample test_scatter_gather.prg
- CALCULATE implemented and now you can define your own aggregatable functions as MySum() and MyCount(). There are two samples showing how to define your own aggregatables functions. See the sample test_calculate01.prg
- DATABASE SUPPORT. There are lots of new commands related to databases. See the samples test_dbcommands_createdatabase01.prg, test_dbcommands_createdatabase02.prg and test_database_functions.prg
- COPY PROCEDURES
- APPEND PROCEDURES
- CREATE DATABASE
- CREATE CONNECTION
- CREATE TRIGGER
- CREATEOFFLINE
- DROPOFFLINE
- DBGETPROP
- DBSETPPROP
- DELETE CONNECTION
- DELETE DATABASE
- DELETE TRIGGER
- DELETE VIEW
- FREE TABLE
- REMOVE TABLE
- RENAME CONNECTION
- RENAME TABLE
- RENAME VIEW
- PACK DATABASE
- VALIDATE DATABASE
Automatic ORM from Tables to Objects
Object Relational Mapping, ORM, is a way to treat your data as objects and to persist your objects into tables. This feature enables several new powerful ways to deal with your data.
- Declare a variable as having the type of a table (i.e. databases::northwind::employees). This allows you to have Compile Time checking of your code to avoid mispelled field names, and wrongly mixing the field types
TLOCAL oEmployees as databases::northwind::Employees
USE "employees.dbf"
oEmployees = GetTableInterface(typeof(databases::northwind::Employees))
? oEmployees.FirstName && OK
? oemployees.addres && Error at compile time the right field name is address
? LEN(oexployees.reportsTo) && error at compile time ReportsTo is numeric not string
And finally you can assign new values to the fields as this:
oEmployees.FirstName = "SomeName"
oEmployees.FirstName = 24 && Error a string is expected not a number
- And this enable to bind ASP.NET Controls to VFP Tables directly, without needing intermediaries DataSet, or DataTables so you have really fast Data Access to your VFP Data. Check the sample binding the Customers Table to an ASP.NET GridView here.
- As added bonus you get faster access to your Visual Foxpro Data than using MyAlias.MyField or just MyField.
- And finally the new function GetTableEnumerator() lets you treat your VFP Tables as an IEnumerator in .NET enabling things as FOR EACH over a VFP Table and specially setting the stage to use LINQ (Language Integrated Query) over VFP Tables. Look at the sample binding a listbox to the Categories table just with this line:
THIS.oListBox.DataSource = GetTableEnumerator(typeof(Databases::NorthWind::Categories))
New Commands
- More commands and functions.
APPEND MEMO
COPY MEMO
ADATABASES()
ADBOBJECTS()
DBC()
INDBC()
DBGETPROP()
DEBSETPROP()
DBUSED()
Several new commands:
EXTERNAL: helpful to give the compiler a hand to solve references
COUNT
TOTAL
SUM
AVERAGE
CALCULATE now supports besides the basic functions (MAX, MIN, SUM, …) VAR_SAMP and STDDEV_SAMP as required by the SQL 2003 Standard. And now you can add your own aggregatable functions. Stay tuned for the samples to appear in the next days for this, hopefully some one will build a sample with COVAR() and CORR().
Miscelaneous enhancements
- Compiler now supports 4 letter abbreviations. This is an optional switch that you have to manually enable it. This is for compiling legacy code using 4 letter abbreviations.
- Run Button "!" is back in .NET. Just click the button to run the active program under .NET. This enable easy testing, that surely is something we missed in .NET. In the next updates we plan to bring the Command Window to .NET.
As you can see we have been VERY, VERY busy improving the capabilities under .NET and enabling new scenarios that now makes working with Data under .NET so enjoyable as in pure Visual FoxPro. With these enhancements there is no match to this power in .NET.
Samuel David