FoxPro Commands Overview – Append, Set, Record, Go to, Skip, Edit, List, Display, Browse, Replace

Here is brief overview and example usage of the basic FoxPro commands like Append, Set, Record, Go to, Skip, Edit, List, Display, Browse and Replace.

  1. Append command is used to add new record in the table. Set status on displays status bar at the bottom of the screen. It shows the screen active database file, the current record pointer position, number of records in the database file. And the command used to close the status bar is
    Set status off
  2. Set default to A is used to change the default root directory from C: drive to A: drive. Set carry on specifies static enter or duplicate for the present record into a new record when the append command is entered. Set carry off command is used to delete or to stop duplication. Dir command displays the database file.
  3. Record Pointer:-

    FoxPro marks its position with a table by means of a internal maker called the record pointer. A table first opens the Record Pointer normally pointing the first record in the table.

  4. Go to:-

    Go 2 command is used to show the positioning of the record pointer on the 2nd record.

    Go Top command moves the record pointer on first record.

    Go Bottom moves the record pointer on last record.

  5. Skip

    command moves the record pointer from the current location to next location. Skip 2 command jumps 2 record. Skip -2 goes back to 2 records, that is current record – 2.

  6. ? RECNO() command displays the current record number.
  7. Modify the Record:-

    To modify data in the existing records the following commands can be used:

    –> EDIT displays the required record to be edited on the screen.
    EDIT fields stuno, stuname, fee: displays the above fields on the screen.
    EDIT For Fee >300 and Fee < 300 EDIT For DOJ = {06/11/09} displays data relating to that date of joining.
    EDIT for DOJ < {06/11/09} EDIT for DOJ > {06/11/09}

  8. Viewing the Record:-

    After adding the record to the table, the next logical step is to view the data. Data can be viewed with the list and display command with the command window.

    The default scope of the List command is to display all the record on the screen. The scope can be changed by using various options of the list command.
    For example,

    –> LIST record 4 displays the record no. 4

    –> LIST stuno, stuname, fee (field name) displays the said field names only.

    –> LIST stuname, Fee +50 displays the figures of student name adding 50 to the previous amount. LIST stuname, Fee -50 displays the figures deducting 50 from previous amount.

    Note: Val is used for the conversion of characters into numeric.

    LIST for Val (marks) > 50

    LIST stuname, Fees x 2 multiplies

    LIST stuname, Fees / 2 divides

    LIST for Fees > 2450 displays the fees greater than the amount 2450.

    LIST for Fees > 2450 and < 4000 displays fee amounts that fall between 2450 and 4000. For ‘and’ condition all conditions should be satisfied. For ‘or’ condition any condition if satisfied it displays the data.

    LIST for stuname = “rao” displays rao’s data only. Here strings used for characters only and for numbers there is no usage of any strings.

    LIST for stuname != “rao” or LIST for stuname <> “rao” displays data except rao’s.

    LIST for stuname = “Raghu” and Fees >200 displays the data for Raghu if the fee is greater than 200. Here note that the character names are unique as in data.

    LIST for doj>{06/11/99} displays data of students joined after the specified date of joining (doj).

  9. Display Command

    Display command is somewhat similar to LIST command. Display All and List command are interchangeable. Both commands display the list of the records in the table. The default scope of the Display command is current record position. For example, using the command, go 6 Display we can display the 6th record.

    Disp all stuno, stuname, fees displays all the field names.

    Disp all stuno for course = “FoxPro” displays the number of students in foxpro course.

  10. Set Headings:-

    Set Headings off command displays the record without the field headings.Set Headings on command displays the records with field headings.

  11. Set Print:-

    The Set Print command sends output to the printer in addition to the screen.

    Set Printer on

    Set Printer to LPT1

    ?Date() command displays the current date (mm / dd /yy)

    Set Date Japan
    ?Date()
    00/07/25

    Set Date Germany
    ?Date()
    25/07/00

    Set Date America
    ?Date()
    07/25/00

    Set Century on
    ?Date()
    07/25/2000

    Set Century off
    ?Date()
    07/25/00

    Set Century off
    LIST

  12. Browse Command:-

    It usually difficult to view a number of records on the screen at the same time. FoxPro browse mode displays the large amount of information at the same time.

    Browse displays the records shows in a spreadsheet format.

    Browse fields stuno, stuname, fee Displays those fields only.
    New record is not acceptable but modifications only acceptable.

    Browse fields stuno, stuname, fee Freeze fee command restricts the edition of the specified field.

  13. Replace Command:-

    The replace command overwrites the contents of the specified fields in a table with new contents. It replaces the contents of only current record. For example,

    Replace all fees with fees + 50 command replaces all the fees adding amount 50 to all.

Leave a Reply

Your email address will not be published. Required fields are marked *