- Definitions
- Sample Structure
- Use - Open/Close Database
- ? - Display In Console
- Moving the Read/Write
- List - List Information From All Records
- Continuation Lines
- Display - Display Information From Current Record With Pause
- Display All - Display Information From All Records With Pause
- Append - Add New Record To End Of Database
- Modify Structure - Alter The Database Layout
- Copy Structure to - Create a New Database With The Same Structure
- To Print - Route A CopyTo Printer
- To File - Route A CopyTo A File
- Edit - Edit Fields Of One Record
- Change- Edit Fields Of One Record
- Clear - Clear Window
- Browse - Spreadsheet Like Browse Window
- Dir - Display File Listing
- Delete - Tag Records For Deletion
- Set Deleted - Adjust The Deleted Filter Toggle
- Recall - Remove Record Deletion Tags
- Pack - Physically Delete Records
- Zap - Delete All Records From Database
- Possible Exam/Quiz Questions - FoxPro B
All of the following FoxPro Commands Can Be Entered Into The Command Window
(these commands are not case sensitive)
Definitions
current record <------> The record pointed to by the read/write pointer
Sample Structure
- NAME Character 26 ADDRESS Character 30 CITY Character 16 STATE Character 2 ZIP Character 8 PHONE Character 12 MALE Logical 1 NO Numeric 4 0 NOTES Memo 4
Use - Open/Close Database
Use <-- close any database open in the current work area.
Use Client <-- close the current database, if any, and open database file Client.dbf in the current work area.
or Use Client.dbf <-- same as above. Specifying the extension is optional.
The FoxPro database program has multiple work areas. Only one database may be opened in each work area.
?- Display In Console
? RecNo () <-- display the current record number (as designated by the read/write pointer). ? RecCount ()<-- display the number of record in the database. ? RecSize () <-- display the number of bytes in one record.
Moving the Read/Write Pointer
5 <-- move read/write pointer to record 5. 1 <-- move read/write pointer to first record.
GoTo RecCount()<-- move read/write pointer to the last record.
Skip 1 <-- move read/write pointer forward 1 to the next record. Skip 2 <-- move read/write pointer forward 2 records. Skip -1 <-- move read/write pointer backward 1 to the next record. Skip -2 <-- move read/write pointer backward 2 records.
List- List Information From All Records
List <-- uninterrupted display of specified fields of all records. List Name, State, Phone<-- uninterrupted display of the Name field, the State field, and the Phone of all records.
List Phone, Name, State<-- uninterrupted Phone field, the Name field, and the State field of all records.
List Name, State For State = "TX" <-- uninterrupted Name field & the State field of all of the Texas records all records.
List Name, State For State = "TX" .And. Male <-- uninterrupted Name field & the State field of all male Texas records.
List Name, State For State = "TX" And Male <-- uninterrupted Name field & the State field of all male Texas records.
List Name, State For State = "TX" .Or. State = "CA" <-- uninterrupted display the Name field & the State field of all Texas and all California records.
List Name, State For State = "TX" Or State = "CA" <-- uninterrupted display the Name field & the State field of all Texas and all California records.
Continuation Lines
List Name, State For State = "TX" ; <-- uninterrupted Name field & the State field of all male Texas records And. Male
Display- Display Information From Current Record With Pause
Display [Fields] <-- interrupted display specified fields of the fields in the current record.
Display Name, State, Phone <-- interrupted display the info stored in the Name field, the State field, and the Phone of the current record.
Display all- Display Information From All Records
Display All Name, State For State = "TX" And Male <-- interrupted display the Name field & the State field of all male Texas records.
Display All Name, State For State = "TX" .Or. State = "CA" <-- interrupted display the Name field & the State field of all Texas and all California records.
Append- Add New Record To End Of Database
Append Blank <-- move the read/write pointer to the end of the file and evoke a very crude editor for data entry. This option is used to add records to customized user-defined screens.
Modify Structure - Alter The Database Layout
copy structure to - Create A New Database With The Same Structure
Copy Structure To A:\New<-- create a database file, called New.dbf, that contains the same structure/layout as the current database. File New.dbf contains no records.
to print- Route A Copy To Printer
List Name, State For State = "TX" To Print <-- display on the monitor and print the Name field & the State field of all of the Texas records.
Display all Name, State For State = "TX" To Print <-- display on the monitor and print the Name field & the State field of all of the Texas records. There display will be interruped by a pause when the screen is full.
Display Name, State To Print <-- display on the monitor and print the Name field & the State field of the current record
List Structure To Print<-- display on the monitor and print a copy of the current database layout/structure (no pause).
To File- Route A Copy To File
List To File A:\Names<-- write all of the information in all of the records to an ASCII file, called Names.txt at the root of the A drive. A copy will also appear on the current window.
List To A:\Names <-- write all of the information in all of the records to an ASCII file, called Names.txt at the root of the A drive. A copy will also appear on the current window.
List Structure To File Struct <-- write the database layout/structure to an ASCII file, called Struct.txt in the current default directory. A copy will also appear on the current window.
List Structure To Struct <-- write the database layout/structure to an ASCII file, called Struct.txt in the current default directory. A copy will also appear on the current window.
List To File A:\Names for State = "TX" to A:\Names <-- write the Name field & the State field of all of the Texas records to an ASCII file, called Names.txt at the root of the A drive. A copy will also appear on the current window.
List To A:\Names for State = "TX" to A:\Names <-- write the Name field & the State field of all of the Texas records to an ASCII file, called Names.txt at the root of the A drive. A copy will also appear on the current window.
Edit - Edit Fields Of One Record
Edit Record 4 <-- move the read/write pointer to record 4 and edit this record with a very crude data entry editor.
Edit 4 <-- move the read/write pointer to record 4 and edit this record with a very crude data entry editor.
Edit Fields Name, StateRecord 4<-- move the read/write pointer to record 4 and edit only fields Name and State of this record with a very crude data entry editor.
Change- Edit Fields Of One Record
Change Record 4 <-- move the read/write pointer to record 4 and edit this record with a very crude data entry editor.
Change 4 <-- move the read/write pointer to record 4 and edit this record with a very crude data entry editor.
Change Fields Name, State<-- change only fields Name and State of the current record with a very crude data entry editor.
Change Fields Name, StateRecord 4<-- move the read/write pointer to record 4 and edit only fields Name and State of this record with a very crude data entry editor.
Clear - Clear Window
Clear All <-- close all databases, erase all memory variables, erase all user-defined menu bars, pop ups, windows, etc.
Clear Memory <-- clear all public and private memory.
clear windows<-- release all user defined window definitions.
Browse - Spreadsheet Like Browse Window
Browse <-- all fields of all records are opened in the browser.
Browse Fields Name, State, Phone <-- the Name field, the State field, and the Phone of all records are opened in the browser.
Browse Fields Phone, Name, State <-- the Phone field, the Name field, and the State field of all records are opened in the browser.
Browse Fields Name, State For State = "TX" <-- the Name field & the State field of all of the Texas records all records are opened in the browser.
Browse Fields Name, State For State = "TX" ; <-- Name & State fields of male Texans opened in browser. And Male
Browse Fields Name, State For State = "TX" Or State = "CA" <-- the Name field & the State field of all Texas and all California records are opened in the browser.
Dir - Display File Listing
Dir *.* <-- display the names of all files in the default directory.
Delete- Tag Records For Deletion
Delete Record 4 <-- move the read/write pointer to record 4 and tag this record for deletion.
Delete All <-- tag all records for deletion.
Delete All For State = "CA" <-- tag all California records for deletion.
There is a system variable, called Deleted, that is a filter used to trap records tagged for deletion. This filter is initially turned off.When the Deleted filter is off, those records tagged for deletion have an asterisk (*) beside the record number in listings; they have a black tag to the left in a browse window.When the Deleted filter is on, those records tagged for deletion simply do not appear in listings; they do not appear in a browse window; they do not appear in reports.
Set Deleted On/Off - Set The Deleted Filter Toggle
Set Deleted Off <-- turns off the deleted filter. Deleted records shall be included.
? Deleted( ) <-- displays .T. if the current record has been tagged for deletion, else .F.
List For Deleted( )<-- display on the monitor all of the information about all of the records tagged for deletion.
List For Deleted() = .T. <-- display on the monitor all of the information about all of the records tagged for deletion.
List For Not Deleted( )<-- display on the monitor all of the information about all of the records not tagged for deletion.
List For Deleted() = .F. <-- display on the monitor all of the information about all of the records not tagged for deletion.
Recall - Remove Record Deletion Tags
Recall Record 4 <-- removes the deletion tag from the record 4.
Recall All <-- removes the deletion tag from all records.
Recall All For State = "CA"<-- removes the deletion tag from all California records.
Recall offers an opportunity to undelete records. This is an important database un-do opportunity.
Pack - Physically Delete Records Tagged For Deletion
Zap - Delete All Records From Database
Eventually, you will make an error entering something in the command window. (See Above) The right quote is missing from WV. Most of the time, a little research and the help system will enable you to correct the error. There will be times that you don't understand why your code did not work; when this happens, print the contents of the command window and seek help. (See Below)
into the command window during this FoxPro session.]