Sunteți pe pagina 1din 3

/**** SANDESH SAWANT ***********/

Useful FoxPro commands


FoxPro is a large and mature language with a wide choice of commands and functions. It can
sometimes be difficult to find just what you want in the Help system when you are starting off. This is a
list of some of the more useful commands and functions.
The distinction between commands and functions is that commands do something whereas functions

just return a value to be displayed or used in another command.

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

These notes are split into sections:



General commands

Files and directories

Tables

Manipulating Numbers

Manipulating Text

Manipulating Dates

Miscellaneous commands

General commands
CLEAR
Clears the screen
CLEAR MEMORY Clears variables from memory
CLOSE DATA ALL
Closes all tables and databases
QUIT
Closes FoxPro

Files and directories


CD <dir>
make <dir>> the current directory.
CD ?
display a directory tree and switch to the directory chosen.
GETDIR()
display a directory tree and returns the directory name as a string.
GETFILE()
displays a file-selection dialog and returns the file name as a string.
GETPICT()
displays a file-selection dialog showing image files and returns the file name as a
string.

Tables
ALIAS(<table>)
return the alias under which <table> is open.
DISPLAY STATUS
display the status of all tables and flags.
DISPLAY STRUCTURE
display the structure of the current table. DBF(<table>)
return the full name and path of <table>.

Manipulating numbers
INT(<number>)
return the integer part of that number.
RAND()
return a random number between 0 and 1.
STR(<number>,
<m>, <n>)
convert number to a string of <m> characters with <n> decimals.
VAL(<text>)
return the numeric value of <text>.

Manipulating text
ALLTRIM(<text>)
return <text> with leading and trailing spaces removed.
AT(<char>,<text>)
return the position of character <char> in string <text> or -1 if <char> is not found.
CTOD(<text>)
return <text> as a date.
DTOC(<date>)
return <date> as a string in 'dd/mm/yy'.
DTOS(<date>)
return <date> as a string in 'yyyymmdd' format.
ISLOWER(<text>)
return .T. if the first letter of <text> is lower case.
ISUPPER(<text>)
return .T. if the first letter of <text> is upper case.
LEFT(<text>, <n>)
return the leftmost <n> characters of <text>.
LEN(<text>)
return the length of <text> - including spaces.
LOWER(<text>)
return <text> as lowercase text.
LTRIM(<text>)
return <text> with leading spaces removed.
PADC(<text>, <n>, <char>)
pad <text> to <n> characters long by adding <char> to both ends.
PADL(<text>, <n>, <char>)
pad <text> to <n> characters long by adding <char> to the start.
PADR(<text>, <n>, <char>)
pad <text> to <n> characters long by adding <char> to the end.
PROPER(<text>)
return <text> in lowercase text with the initial letters capitalised. Not as useful as you might think because many proper names include
a mixture of uppercase and lowercase letters.
RIGHT(<text>, <n>)
return the rightmost <n> characters of <text> including spaces.
RTRIM(<text>)
return <text> with trailing spaces removed.
STRTRAN(<text>, <a>, <b>)
replace every occurrence of <a> inside <text> with another character or characters <b>.
STUFF(<text>, <m>, <n>, <a>)
replace <n> characters from position <m> in <text> with the character or
characters <a>.
TRIM(<text>)
identical to RTRIM.
SUBSTR(<text>,<m>,<n>)
return <n> characters from within <text> starting at character <m>.
UPPER(<text>)
return <text> in upper case text.

Manipulating dates
CDOW(<date>)
return the name of the day of the week of <date>.
CMONTH(<date>)
return the name of the month of <date>.
DATE()
return today's date.
DATE(<yyyy>,<mm>,<dd>)
return a date variable holding dd/mm/yyyy.
DMY(<date>)
return <date> in full as text.
DOW(<date>)
return the day of the week of <date> as a number.
GOMONTH(<date>, <n>)
return a date <n> months after <date>.
MONTH(<date>)
return the month of <date> as a number.
SET CENTURY OFF
hide the century digits when dates are displayed. Note that the century is still stored.
SET CENTURY ON
show with the century digits when dates are displayed.
SET CENTURY TO <cc>
ROLLOVER <yy>
set a 100-year window for years entered as two digits.
<>
Miscellaneous
EMPTY()
return .T. if field or variable <name> is empty.
GETCOLOR()
display a colour picker and return the code for the colour chosen.
ISNULL()
return .T. if field or variable <name> is a null.
TYPE()
return a code showing whether <name> is numeric, text, etc.

S-ar putea să vă placă și