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:

    Wise Draco comes, deep in the midnight roll
    Of black artillery; he comes, though late;
    In code corroborating Calvin’s creed
    And cynic tyrannies of honest kings;
    He comes, nor parlies; and the Town, redeemed,
    Gives thanks devout; nor, being thankful, heeds
    The grimy slur on the Republic’s faith implied,
    Which holds that Man is naturally good,
    And—more—is Nature’s Roman, never to be
    scourged.
    Herman Melville (1819–1891)

    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)