Visual FoxPro functions for numbers

FoxPro is a database program not a specialist package for mathematics or statistical analysis but it does provide most of the basic mathematical tools. If Visual FoxPro does not support the function you want, consider using Automation to call Excel.

Here is a list of some of the more useful commands and functions. Many of them accept extra optional parameters. Look in the FoxPro Help system for more information about their use and syntax.

Note that FoxPro syntax requires that functions are always followed by a pair of brackets - even if there's nothing in them.

<num1> % <num2> return the remainder after dividing <num1> by <num2>
<num1> ** <num2> return <num1> to the power <num2>
<num1> ^^ <num2> return <num1> to the power <num2>
ABS(<num>) return the absolute value of <num>.
ACOS(<num>) return the arc cosine of <num> as radians. Also ASIN(), ATAN() and ATN2().
CALCULATE TO (<var>) Perform calculations on a field from a table and store the result in a variable named <var>. More details about the options available.
CEILING(<num>) return the integer equal or greater than <num>.
COS(<num>) return the cosine of <num> radians. Also SIN() and TAN().
COUNT TO (<var>) store the number of records in a table and store the result in a variable named <var>. The Calculate command has a similar function.
DTOR(<num>) return the equivalent of <num> radians in degrees.
EXP(<num>) return e number.
FLOOR(<num>) return the integer equal or less than <num>.
INT(<num>) return the integer part of <num>.
LOG(<num>) return the logarithm of <num> to the base e.
LOG10(<num>) return the logarithm of <num> to the base 10.
MAX(<a>, <b>, <c>, ...) return the maximum value from the list.
MIN(<a>, <b>, <c>, ...) return the minimum value from the list.
MOD(<num1>, <num2>) return the remainder after dividing <num1> by <num2>.
RAND(<num>) returns a random number between 0 and 1 using <num> as the seed for the random number generator.
ROUND(<num2>,<num2>) return <num1> rounded to <num2> decimal places.
RTOD(<num>) return the equivalent of <num> degrees in radians.
SIGN(<num>) return -1, 0 or +1 if <num> is negative, zero or positive.
SET DECIMAL TO(<num>) display numbers with <num> decimal places.
SET FIXED ON|OFF determine whether to display all numeric results with a fixed number of decimal places.
STR(<num>,<m>,<n>) return <num> as a string variable of <m> characters rounded to <n> decimal places.
SUM TO (<var>) Calculate the sum of a field from a table and store the result in a variable named (<var>). The Calculate command has a similar function.
VAL(<text>) returns the numeric value of <text>.

Access Tips

FoxPro Tips

General Tips

 

Related Items

FoxPro Functions

FoxPro has always had functions like FREAD and FWRITE to read and write files at a low level. They can handle files which defeat the newer STRTOFILE and FILETOSTR functions in Visual FoxPro.

Read More

Useful Visual FoxPro Commands

Description of the syntax for some useful Visual FoxPro commands and functions.

Read More

American date formats used by Access SQL

Microsoft Access uses an American date format in some SQL commands.

Read More

Visual FoxPro functions for file names

FoxPro functions to process files and folders.

Read More

FoxPro functions for manipulating text

Foxpro commands and functions for text processing.

Read More