Data Displaying and Monitoring Commands - DISPLAY, LIST, LOCATE, EDIT, CHANGE, BROWSE, REPLACE, DELETE, RECALL, PACK (All Commands with various Options) Modify Structure, Memo Field And File Utilities

  1. Definitions
  2. Sample Structure
  3. Use - Open/Close Database
  4. ? - Display In Console
  5. Moving the Read/Write
  6. List - List Information From All Records
  7. Continuation Lines
  8. Display - Display Information From Current Record With Pause
  9. Display All - Display Information From All Records With Pause
  10. Append - Add New Record To End Of Database
  11. Modify Structure - Alter The Database Layout
  12. Copy Structure to - Create a New Database With The Same Structure
  13. To Print - Route A CopyTo Printer
  14. To File - Route A CopyTo A File
  15. Edit - Edit Fields Of One Record
  16. Change- Edit Fields Of One Record
  17. Clear - Clear Window
  18. Browse - Spreadsheet Like Browse Window
  19. Dir - Display File Listing
  20. Delete - Tag Records For Deletion
  21. Set Deleted - Adjust The Deleted Filter Toggle
  22. Recall - Remove Record Deletion Tags
  23. Pack - Physically Delete Records
  24. Zap - Delete All Records From Database
  25. Possible Exam/Quiz Questions - FoxPro B


  26. All of the following FoxPro Commands Can Be Entered Into The Command Window
    (these commands are not case sensitive) 

    Definitions
    read/write pointer <--> An invisible record pointer that floats through a database file.
    current record <------> The record pointed to by the read/write pointer 
     


    Sample Structure
    Let us assume the Client.dbf for the following illustrations. The structure/layout is as follows:
      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 FileName <-- close any database open in the current work area and opens the specified database. The database must have a .dbf extension. The read/write record pointer is positioned at the first record when file is opened/re-opened.
    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
    ? 3 * 4 <-- display the product of 3 * 4 - 12 ? "3" + "4"<-- display the concatenation of "3" + "4" - 34 ? 2 ^ 3 + 3 * 2 - 1<-- display the calculation of 2 ^ 3 + 3 * 2 - 1 - 13
    ? 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
    GoTo Top <-- move read/write pointer to first record. GoTo 1 <-- move read/write pointer to first record. GoTo 5 <-- move read/write pointer to record 5. GoTo Bottom <-- move read/write pointer to the last record.
    <-- move read/write pointer to record 5. <-- 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 [fields] <-- an uninterrupted display of database information. The list command will always move the read/write pointer to first logical record and display all of the fields of all records. Upon completion, the read/write pointer will always reside at the end of the file. Since the display is uninterrupted, there will be no pause when the screen is full.
    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
    It is important to keep lines reasonable in length; lines more than 80 characters will not necessarily print in their entirety. When a semicolon is placed at the end of a line, it can be broken and extended to the next line. See below.
    List Name, State For State = "TX" ; <-- uninterrupted Name field & the State field of all male Texas records And. Male
    Since the command window will allow you to enter very long lines (255 characters), most database programmers do not frequently use the continuation (;) within that window. You may use the continuation within the command window if you use the down arrow key to get to the next line.
     



    Display- Display Information From Current Record With Pause
    Display <-- an interrupted display of database information. The display command will display all of the fields of the current record. Upon completion, the read/write pointer remains unchanged. There will be a pause when the screen is full.
    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 <-- an interrupted display of database information. The display all command will always move the read/write pointer to first logical record and display all of the fields of all records. Upon completion, the read/write pointer will always reside at the end of the file. Since the display is interrupted, there will be a pause when the screen is full. With the exception of the pause, the display all command is identical to the listcommand.
    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 <-- move the read/write pointer to the end of the file and evoke a very crude editor for data entry. Append is used to add additional records to the 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
    Modify Structure<-- alter the database layout/structure. The modify structure command returns you to the file/creation program. You will have the opportunity to change the name of the fields, change the field datatypes, change field sizes, add fields, delete fields, and/or reorder fields.
     


    copy structure to - Create A New Database With The Same Structure
    Copy Structure To FileName <-- create a database file, called FileName, that contains the same structure/layout as the current database. The new file has 0 records.
    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
    Adding To Print to the end of any Display command or any List command sends a copy of the output to the printer, as well as the current user defined window. List is more often used with to print.
    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
    Adding To File to the end of any Display command or any List command sends a copy of the output to the designated file, as well as the current user defined window. The default extension on the file will be txt. List is more often used with to generate files.
    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 <-- edit the current record with a very crude data entry editor. (See Above)
    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, State<-- edit only fields Name and State of the current record with a very crude data entry editor. (See Above)
    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 <-- change the current record with a very crude data entry editor. The Change command is identical to the Edit command.
    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 <--- clear the current user-defined window (desktop if none).
    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 [fields] <-- the browser is a tabular editor in which each record is manipulated on a single line. The browser opens a resizable, movable, slide-bar window which contains the field names across the top. The simple browser allows any fields to be edited/changed. New Records may be appended at the end of the browser.
    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 names, number of records, size in bytes, and date of last update for all databases (.dbf extension) in the default directory.
    Dir *.* <-- display the names of all files in the default directory.
     


    Delete- Tag Records For Deletion
    Delete <-- tags the current record 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 On<-- turns on the deleted filter. Deleted records fail to pass through.
    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 <-- removes the deletion tag from the current record.
    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
    Pack <-- permanently removes all records tagged for deletion.
     


    Zap - Delete All Records From Database 
    Zap <-- permanently removes all records. 

    Possible Errors In The Comand Window


    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)
    File-->Print            [Using the mouse, hold down the File Menu and Select Print to print all of the commands entered
                                                into the command window during this FoxPro session.]