Está en la página 1de 11

AVERAGE Syntax:AVERAGE [<num exp list>] <scope>] [FOR <exp>][WHILE <exp2>] [TO <memvar list>|TO ARRAY <array>][NOOPTIMIZE] This

command computes the average of numeric expressions. By default, all the Numeric fields in the current database are averaged.
COUNT Syntax: COUNT [<scope>] [FOR <expL1>][WHILE <expL2>][TO <memvar>] [NOOPTIMIZE]

CALCULATE [791] Syntax: CALCULATE[<scope>] <math exp list> [FOR <expl1>][WHILE <expl2>] [TO <memvar list>| TO ARRAY <array>] [NOOPTIMIZE] This command lets you perform a variety of mathematical operations on database fields or fields or field expressions. CANCEL Syntax: CANCEL

This command terminates execution of a program, releases all private memory variables, and returns control to the FoxPro Command window or to DOS. CLEAR (797) Syntax: CLEAR |ALL|FIELDS|GETS|MACROS|MEMORY|MENUS|POPUPS| PROGRAM|PROMPT|READ|TYPEHEAD|WINDOWS CLOSE (799) Syntax: CLEAR |ALL|ALTERNATE CREATE LABEL [805] CREATE MENU [806] CREATE QUERY [808] CREATE REPORT [808] DEACTIVATE MENU [813] DEACTIVATE POPUP - 813 DEACTIVATE WINDOW - 813 DECLARE 814 DEFINE BAR 815 DEFINE MENU 816

DEFINE PAD817 DEFINE POPUP 819 DEFINE WINDOW 821 DISPLAY MEMORY 829 DISPLAY STATUS 829

List of Fox Pro commands


1. CREATE 2. USE 3. DISPLAY SCOPE[ALL, REST, NEXT, RECORD, FOR, WHILE]/OFF/FILLDS 4. LIST SCOPE[REST, NEXT, RECORD, FOR, WHILE]/OFF/FILLDS 5. EDIT 6. BROWS LOCK n/FREEZ 7. APPEND/APPEND BLANK /APPEND FROM 8. GOTO/GOTO TOP/GOTO BOTTOM/GOTO RECORD n 9. SKIP/SKIP n/SKIP n 10. DELETE 11. DELETE FILE 12. RENAME 13. COPY 14. REPLACE 15. MODIFY STRUCTURE 16. DISPLAY STRUCTURE 17. LOCATE 18. CONTINUE 19. MACRO SUBSTITUTION
20. SUM,AVERAGE,COUNT

21. SORT 22. INDEX 23. FIND 24. SEEK 25. JOIN 26. MACRO 27. SET RELATION 28. UPDATE 29. CLEAR(797) Syntax:CLEAR [ALL CLOSE (799)

Fox Pro Programming


1. 2. 3. 4. DATA TYPE OPERATOR CANTROL FLOW STATEMENT i. IF[ SIMPLE IF, IF-ELSE, NESTED IF, IIF] ii. DO CASE LOOPING STATEMENT i. FOR [SIMPLE AND NESTED] ii. DO WHILE [SIMPLE AND NESTED] iii. SCAN END..SCAN ARRAY i. SINGLE DIMENSION ii. DOUBLE DIMENSION iii. MULTI DIMENSION FUNCTIONS i. LIBRARY FUNCTIONS ii. USER DEFINE FUNCTION(UDF) SCATTER GATHER COPY TO ARRAY PROCEDURE REPORT QUARIES LABLE FORM

5.

6. 7. 8. 9. 10. 11. 12. 13. 14.

CREATE:- This command lets you define the structure of a new database file. The database file is given an extension .DBF. Syntax:CREATE [<filename>]

USE:- To open an existing database file. The command USE without any file name will close the current active dbf file. An active dbf file will automatically get closed whenever you open another dbf by using USE command. Syntax: USE [<file name>]

DISPLAY :- DISPLAY command will display the contents of the current record on the screen.
Syntax: DISPLAY [SCOPE] [FIELDS <field exp list>] [FOR <exp1>] [WHILE <exp2>] [OFF] [TO PRINTER| TO FILE <file name>] [NOOPTIMIZE] If an optional Scope clause is used, such as NEXT<expN>, RECORD <expN>, ALL, REST, all the records included in the specified scope will be displayed on the screen. If an optional FIELDS clause is used, only the fields listed are displayed on the screen. If a FOR clause is used, all the records included in the specified scope for which the logical expression following the FOR is evaluated as true are displayed on the screen.

Examples :DISPLAY ALL FOR TOTAL>400 (displays all records where the total is greater then 400) DISPLAY ALL FOR TOTAL<>400 (displays all records where the total is not 400) DISPLAY ALL FOR TOTAL>400 AND TOTAL<500 (displays all records where the total is greater then 400 and less then 500, i.e., both the conditions must be true for satisfying criteria.) DISPLAY ALL FOR NAME=AMIT OR TOTAL<400 (displays all records where the NAME is AMIT or TOTAL is less then 400, i.e., only one condition is required to be true for the satisfying criteria.)
A WHILE clause will display all successive records that matches the specified criteria. All matches after a mismatch will not be consider for the applied command.

Ex:-

DISPLAY ALL WHIL TOTAL<500

This command will display records until fox pro find a TOTAL>=500. All records after that records having TOTAL<500 will not be displayed. If the OFF clause is used, the record number is not displayed. The optional TO PRINTER or TO FILE<filename> cause lets you send the display to the printer or to the text file whose name is specified.

The NOOPTIMIZE option disables the Rushmore technology, which normally speeds up data access when you use a FOR statement.

LIST :LIST command will display all records. The default scope of the LIST command is ALL. We can apply all the scope to list command [accept current].
Syntax: DISPLAY [SCOPE] [FIELDS <field exp list>] [FOR <exp1>] [WHILE <exp2>] [OFF] [TO PRINTER| TO FILE <file name>] [NOOPTIMIZE]

EDIT/CHANGE:- We can edit/modify the records through EDIT command. The default scope of the command is CURRENT. The EDIT command will show an edit window with current record for editing. After changing the values we have to save changes by pressing Ctrl+W.
Syntax:EDIT [FIELDS<fields list>] [FOR <expL1>] [FREEZE <field name>] [KEY <exp1> [,<exp2>]] [LEDIT][REDIT] [LOCK <expN1>] [NOAPPEND][NODELETE] [NOEDIT|MODIFY]

BROWS:BROWS command is also used to edit/modify records of the currently active table. The only difference is the way the brows window and edit window appears on the screen.
Syntax:BROWSE [FIELDS<fields list>] [FOR <expL1>] [FREEZE <field name>] [KEY <exp1> [,<exp2>]] [LEDIT][REDIT] [LOCK <expN1>] [NOAPPEND][NODELETE] [NOEDIT|MODIFY]

The FIELDS option makes the Browse window contain only the fields mentioned in the field list. The FOR option includes only those records for which a logical expression that you specify is true. The FREEZE option allows changes to be made only to the one field that is mentioned, although all the fields are displayed. The KEY option lets you select a particular subset of records to browse by specifying one particular field value or a range of field values to be matched. The database must be indexed on the field you select and the index must currently be in use. The default LEDIT option displays fields horizontally across the screen, while the REDIT option displays them vertically. The LOCK option lets you specify the number of fields to be locked in the browse window. The NOAPPEND option makes it impossible to add new records to the file. The NODELETE option makes it impossible to mark records for deletion. The NOEDIT|NOMODIFY option makes it impossible to make any changes in the data.

BROWS LOCK n:- This command will lock n left most fields(columns). That means the n
leftmost fields will not scroll while others will.

example: BROWS LOCK 2 BROWS FREEZ:APPEND:Syntax:This command will restrict the users access to only specified field. example: BROWS FREEZ NAME APPEND command lets you add new records at the end of the current

database file.
APPEND

APPEND BLANK :- This command add a single blank record to the end of database file and
moves the record pointer to that record. We can later enter values in the appended record by using EDIT/BROWS/REPLACE commands. Syntax:APPEND[BLANK]

APPEND FROM:- APPEND FROM command lets you add records from another table specified with command. We can also append selected records or fields of the specified table by including the FOR or FIELDS clause.
Syntax:APPEND FROM <file> [FIELDS<fieldlist>] [FOR <exp>]

The FIELDS options lets you select which fields in the dbf file will have data appended to them. The FOR option allows you to select which records in the other file will be added to the dbf file that is currently open. Only records for which the logical expression is evaluated as true(.T.) are added. APPEND GENERAL :- This command allows you to import data from another application such as Lotus or Excel into a fox pro database. Syntax:APPEND GENERAL<general field name> FROM <file name> GO|GOTO:- We can use GO or GOTO command to move on a particular record. There are several switch to specify the destination record.
Syntax: GO|GOTO [RECORD] <expN1>|TOP|BOTTOM [IN<expN2>|<alias>] GOTO TOP:- Will move the record pointer to the first record. GOTO BOTTOM:- Will move the record pointer to the last record. GOTO RECORD n:- Will move the record pointer to the nth record.

SKIP:- This command moves the pointer in a database file, changing the record that is the current record. Used by itself, SKIP moves the pointer of the database file that is open in the current work area to the next record; that is, it moves the pointer forward one

record. The optional numeric expression <expN1> can be used to move the pointer forward the number of records that is specified. If a negative number is used, the pointer moves back that number of records. Syntax: SKIP[<expN1>] DELETE:- This command marks records for deletion. In its simplest form, it marks only the current record for deletion. Syntax: DELETE[<scope>][FOR<expL1>][WHILE<expL2>][NOOPTIMIZE] DELETE FILE:This command is used to delete the specified file. The file you want to delete should not be in use. Syntax: DELETE FILE [<file name>] RENAME:This command gives a new name to a disk file. The file that had been named <filename1> is named <filename2> instead. The full path name of files may be used. When this command is used, there must already be a file named <filename1> and it must not be open. There must not be a file named <filename2>. Syntax: RENAME <filename1> TO <filename2> COPY FILE:- This command makes an exact copy of the first file named. If the second file does not exist, it creates it. Syntax: COPY FILE <filename1> TO <filename2> COPY STRUCTURE:Syntax: COPY STRUCTURE TO <file name> [FIELDS <fields list>] [[WITH] CDX|[WITH] PRODUCTION]] REPLACE:- In its simplest form, this command puts new data into one field of the current record. The current data in the field is replaced with <exp1>. The command can also be used with additional fields and expressions to replace the data in all of the fields that are listed. Syntax: REPLACE[<scope>]<field1> WITH <exp1> [ADDITIVE] [<field2> WITH <exp2> [ADDITIVE].][FOR <exp1>][WHILE <exp2>][NOOPTIMIZE] example:
REPLACE ALL CITY WITH DELHI REPLACE ALL TOTAL WITH M1+M2+M3 REPLACE ALL PER WITH TOTAL/3 REPLACE ALL GRADE WITH S FOR PER>85

MODIFY STRUCTURE:- This command is used to modify(change) structure of the current database file.

DISPLAY STRUCTURE:- This command displays the file structure of the current database file. LOCATE:- This command searches the current database file until it finds the first record in which the logical expression following FOR is evaluated as true. Syntax: LOCATE FOR <exp1>[<scope>][WHILE <exp2>][NOOPTIMIZE] LOCATE FOR NAME=AJAY (This command will move the record pointer to the first record having AJAY in its NAME field.) CONTINUE:-This command finds next record that matches the criteria specified with a successful LOCATE.
Syntax:CONTINUE

SORT:To arrange the records of currently open file in a new dbf file in a particular order (ascending or descending) on a specified field. syntax: SORT TO <filename> ON <field1>[/A][/C] [/D][,>field2>[/A][/C][/D]] [<scope>]
[FOR<exp1>][WHILE <exp2>][FIELDS<field list>][NOOPTIMIZE]

/A for ascending order /D for descending order /C for ignoring character case In its simplest form, this command sorts the file that is open in the current work area, based on the field that is specified, in ascending order, and it puts the result in the file that is specified. The SORT command uses temporary work files as well as creating a new output file, so it uses up to three times as much disk space as the space occupied by the original file. INDEX:This command creates an index file for the database that is open in current work area. The index arranges records in an order based on the field expression; the actual order of the records in the database file does not change. The field expression may not use Memo or General fields. Syntax: INDEX ON <field exp> TO <.IDX file>| TAG <tag name> [OF <.CDX file>] FOR<expL>] [COMPACT] [ASCENDING|DESCENDING][UNIQUE] [ADDITIVE] [NOOPTIMIZE] INDEX TO<file name> creates a single-index file in a file with the name that is specified that holds only one index. FoxPro assumes an .IDX extension for the index file, but this default can be overridden by specifying a name that included a different extension. INDEX TAG<tag name> creates a tag of a compound index file. CDX files contain multiple index tags within one file. If you do not specify a file name, FoxPro makes this a tag of the structural compound file, which has the same name as the database file and is

automatically opened whenever the database file is opened. If you specify OF<CDX file name>, FoxPro makes this a tag of some other compound index file. Indexes are updated automatically if they are open when the database file is modified, or they may be updated using the REINDEX command. The ADDITIVE option allows previously opened index files to remain open while you create a new index.

INDEXING

SIMPLE INDEX [.IDX]

COMPOUND INDEX [.CDX]

STRUCTURAL

INDEPENDENT

SIMPLE INDEX INDEX ON KEY-FIELD-NAME TO NEW-INDEX-FILE Fox pro gives a .idx extension to simple index file. COMPOUND INDEX A compound index file contains more then one index. These indexes are called TAGs. Fox pro gives a .cdx extension to the compound index file.

FIND Syntax: FIND <expC> This command finds the first record that matches the character string you specify. The database must be indexed on the corresponding field and that index must be the major index.

FIND is similar to the SEEK command, except that it requires a literal as the basis of its search and cannot search for expressions that use functions or variables.

También podría gustarte