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:

    Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a “sock” in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.
    George Bernard Shaw (1856–1950)

    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)