Visual FoxPro - Code Samples

Code Samples

The FoxPro language contains commands quite similar to other programming languages such as Basic. Loops include do, if, while, for, else commands in a usage easily understood by anyone familiar with other programming languages. Commands take the form of "command" and "endcommand"

Some basic syntax samples:

FOR i = 1 to 10 x = x + 6.5 ENDFOR IF i = 25 i = i + 1 ELSE i = i + 3 ENDIF x = 1 DO WHILE x < 50 x = x + 1 ENDDO x = 1 DO WHILE .T. x = x + 1 IF x < 50 LOOP ELSE EXIT ENDIF ENDDO nMonth = MONTH(DATE) DO CASE CASE nMonth <= 3 MESSAGEBOX("Q1") CASE nMonth <= 6 MESSAGEBOX("Q2") CASE nMonth <= 9 MESSAGEBOX("Q3") OTHERWISE MESSAGEBOX("Q4") ENDCASE FOR EACH oControl IN THISFORM.Controls MESSAGEBOX(oControl.Name) ENDFOR f = Factorial(10) FUNCTION Factorial(n) LOCAL i,r r = 1 FOR i = n TO 1 STEP -1 r = r * n ENDFOR RETURN r ENDFUNC

Hello World example:

MESSAGEBOX("Hello World")

Read more about this topic:  Visual FoxPro

Famous quotes containing the words code and/or samples:

    ... the self respect of individuals ought to make them demand of their leaders conformity with an agreed-upon code of ethics and moral conduct.
    Mary Barnett Gilson (1877–?)

    Good government cannot be found on the bargain-counter. We have seen samples of bargain-counter government in the past when low tax rates were secured by increasing the bonded debt for current expenses or refusing to keep our institutions up to the standard in repairs, extensions, equipment, and accommodations. I refuse, and the Republican Party refuses, to endorse that method of sham and shoddy economy.
    Calvin Coolidge (1872–1933)