Monthly Archives: May 2012



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


Javascript does not have strongly typed variables. In that it is similar to VFP.

Variables are created with the var keyword, similar to the LOCAL keyword in VFP. On creation they do not get any value initially unless assigned.

Variable scoping will be discussed after discussing anonymous functions.

Variable names in javascript are case sensitive.

var a = 100;
var A = 10;
alert(a); gives 100
alert(A); gives 10

This can be a pitfall for VFP developers are we are not used to it. If you start getting wrong results, check the capitalization of variables. Also, sometimes… Continue reading

This is the first in a series of blog I am planning to write to document my experience in the differences in development of software between VFP and JavaScript.

Topics in this series are not going to be covered indepth. Neither am I well versed in javascript. So this will just be a supplementary to your other sources

JavaScript is based on the c language and it borrows it syntax from c. It is similar to VFP with some differences.

Statements end with a ;

Multiple statments are grouped together inside {}


Flow Control

JavaScript has equivalent control flow… Continue reading