Java script for foxpro developers

Preview:

Citation preview

JavaScript for FoxPro Developers

Mike Feltman

F1 Technologies

Who Am I?

• President F1 Technologies since 1990

• Co-author Visual FoxExpress

• Consultant

Agenda

• Why JavaScript?

• VFP vs. JavaScript

• JS Basics

• JS Syntax & VFP Concordance

• JS OOP

• AJAX w/ VFP

Why JavaScript?

• Web 2.0

• Great way to take VFP Skills to the Web

• In demand

• Cross-Platform

• Relatively easy for VFP Developers to pick up

VFP vs. JavaScript: Runtime Environment

VFP– Operating System:

• Windows

Version:• VFP Compiler Version

JavaScript– Operating System:

• Windows, MAC, Linux, Unix, etc.

Version:• Browser Controlled: IE,

Firefox, Opera, Safari, etc.

• 1.5 current “standard”

VFP vs. JavaScript: Development Environment

VFP– Designers: Editor, Form

Class Designer, Report Write, Class Browser, etc. built-in.

– Debugger: Integrated debugger, with Trace, Watch, Locals, Output, Call Stack

– Command Window

JavaScript– Designers: n/a, Requires

3rd Party tools. No definitive IDE

– Debugger: virtually nothing native. Varies by browser, Firebug for Firefox and Debugbar for IE.

– JavaScript Console various other Command Window like utilities.

VFP vs. JavaScript: Capabilities

VFP– Access to File System– Database Engine– Network access limited

only by network security

JavaScript– No File System

Access– Can’t read or write to

files on server– Can’t read or write to

files on client– No network access– Cannot access pages

on another domain

VFP vs. JavaScript: Language Features

VFP – Dynamically Typed– Case Insensitive– “Second Class”

Functions– No Nested Functions– Compiled or

Interpreted– OOP: Class Based– “1 based”

JavaScript– Dynamically Typed– Case Sensitive– First Class Functions– Nested Functions– Interpreted– OOP: Prototype based– “0 based”

Syntax

VFP– Line Terminator:

carriage return– Line Continuation:

semi-colon

JavaScript– Line Terminator: semi-

colon– Line Continuation: n/a

Math Operators

Function VFP JavaScript

Addition + +

Subtraction - -

Multiplication * *

Division / /

Modulus MOD() %

Unary addition x=x+1 x++

Unary subtraction

x=x-1 x--

Assignment Operators

Function VFP JavaScript

Equality = =

Addition n/a +=

Subtraction n/a -=

Multiplication n/a *=

Division n/a /=

Modulus n/a %=

Comparison Operators

Function VFP JavaScript

Equality =,== ==

Greater than >, >= >, >=

Less Than <, <= <, <=

Identical & of Same Type

n/a ===

Not Identical !=,!==,<> !==

Inline IF IIF() (condition)?true value: false value

Logical Operators

Function VFP JavaScript

And AND &&

Or OR ||

Not NOT, ! !

Constructs: If

VFP:

IF

statement(s)

ELSE

statement(s)

ENDIF

JavaScript:

if (logical expression)

{statement(s)}

else if (logical expression)

{statements}

else

{statement(s)}

Constructs: While

VFPDO WHILE expression

statements

ENDDO

EXIT

LOOP

JavaScript

while (expression)

{

statements

}

break

continue

Constructs: For

VFPFOR var = n to n STEP n

statements

ENDFOR

JavaScript

for (var=startvalue;var<=endvalue;var=var+increment)

{

statements

}

Object Model

Event Model

Forms

3rd Party

Recommended