An error handler needs to give as much information about the current state of the software as possible to find the reason for errors.

Some of the information can be found in VFP by commands like LIST MEMORY and LIST STATUS.

I also like to have the values of each control in the active form.

For that I recursively scan all controls in the form, finding controls that have a property called value and printing that out. Pageframes and Containers are recursed into. For grid I select the grid record source and then print the value of the control source… Continue reading

We would like the user to be able to select different printers and paper size for each report. This setting could be set up and saved once.

To do that, we can create a form as below

To do this, we first create a table called ReportNames.dbf. To create it use command

create table REPORTNAMES (ID int autoinc,REPORT Char(20),NARRATION Char(100))

In this we will enter all frx/lbl file names and their description. This table can then be included in the exe as it will be readonly.

The second table is printers.dbf.

create table PRINTERS (ID int autoinc,REPORTNAME Char(20),PRINTERNM Char(100),PAGESIZE int,PAGENAME… Continue reading

If we run out of space on a form, we generally use pageframes. We can also put the information on collapsing containers that we can implement with the class enclosed.

This is a subclass of an image class that can be dropped on any container to allow it to collapse / Expand.

It has the following properties

minHeight - Minimum height to which it will collapse. Keep at least 25 to show the image
minWidth - Minimum width to which it will collapse. Keep at least 25 to show the image
maxHeight - Height that it will expand to
maxWidth… Continue reading

This is a class to drag/drop files from windows explorer and link it to a record in our database.

The class is an image with a folder icon. You first assign it with a Key ID. This is the id that will link to the record. So if you want to open files attached to Client with ID=100, you could make the Key ID = 'CLIENT100'.

The class can also be made invisible and used as an helper class to add files. Eg. adding a picture to an employee record.

The class has properties

1. KeyValue - this is the… Continue reading

This is a class for password gestures. You can get more information about password gestures at http://www.tested.com/news/news/3305-windows-8-turns-gestures-into-powerful-passwords/. The class I have created incorporates clicks and lines. Arcs are not implemented in this class.

This class has 2 properties
showClicks - Make it .T. to when setting password so user can see what is happening. Make it .F. when user is being authenticated.
allowedError - The size in pixel of the grid. The bigger, the easier it is to enter, but the less number of square and so less secure

The class has 3 method
setImage - Sets the image.… Continue reading

I have created a class to convert VFP to Excel. It does not need anything to be installed as it does not use Excel Automation or any OLE DB driver. It however creates Excel XML file so can only be read by Office 2003 and later.

Since it is a VFP only code, it can be subclassed and you can do things like create formatted excel workbooks. You can check out http://msdn.microsoft.com/en-us/library/aa140066.aspx for the XML definitions.

This class uses code from Alejandro Sosa ExcelListener.

LATER Updated the class so it saves the XML in chunks of 5MB to prevent "String too Long" error.


Define Functions

Function definition in Javascript is similar to VFP or any c language. You can define function with

function FunctionName(parameter list){
Body of function


function max(a,b){
if (a>b)
return a;
return b;

Which would be the equivalent of VFP function
Function max(a,b)
If a>b
Return a
Return b

Functions as objects

In javascript, functions are objects and can be assigned to variables or send to other functions as parameters. This is a concept totally different from anything in VFP. A similar functionality in VFP would require macro substitution.
eg. To start a timer,… Continue reading



Javascript class definitions are done differently to VFP class definitions.

To define a class we create a function with the same name as the class name. This function will be the equivalent of the init function in VFP and the class will be based on the VFP custom baseclass.

So we can have

function circle(){


var x = new circle();

This will create an object of class circle which is empty.

We will now change this to add properties

function circle(radius){



var x = new circle(10);

We have now added a property called radius to… Continue reading

Error Handling

Javascript does not have a global ON ERROR command. It does have a Try / Catch which is similar to the VFP try/catch

catch (err){

In VFP we have DEBUGOUT to send information to the debugger's output window. The same can be done in javascript with the console.log function.
console.log('Some Message');
will send the message to the console.


I have used Safari browser to debug javascript. To get to the debugger in Safari, you first have to turn the Developer menu on ( Preferences - Advanced - Show develop menu in menu bar).

Choosing… Continue reading


Unlike VFP, javascript has the ability to have multiple threads running at the same time built into it. This keeps the UI responsive while tasks are taking place in the background. In VFP, if we give a time consuming SQL query, we find that VFP stop responding till the query is complete.

Generally asynchronous commands in javascript are for
1) Querying the Web Server for some information / Sending updates to the Web Server. This is via AJAX
2) Querying a local database.
In both cases, the process can take a few seconds. The general method is to… Continue reading