You are on page 1of 22

Low Level Language

It is a first generation language and second generation language, which are (machine
language and assembly language). It is known as low level language because in this
generation implementation takes place directly on machine level.
Advantages :Speed :- Because implementation takes place directly on machine level, so speed was
very fast.
User can create more powerful application or program.
Disadvantages :Hardware knowledge require
These languages do not allow to implement logic in the natural form.
Third generation language
Third generation language are more efficient and easy to use than second generation
language.
Third generation language do not handle database efficiency.
Database :DBMS :- Data base management System
RDBMS :- Relational Data Base Management System
Database :- Collection of data files.
Data files :- Collection of related records.
Records :- Collection of data information.
Data :- it is a lowest form of data and information.
DBMS :- It is a collection of rules which specify how to manage our database
Or
It is the collection of organized and related information. Eg. Foxpro, Dbase III.
RDBMS :- it specify some rules that extract a unique information at a given point of
time. Eg Oracle, Foxpro 2.6, SQL server, M.S.Access.

Fourth Generation Language :- It is a concept of DBMS and RDBMS


Dr. Codd :- was a scientist gave 12 rules.
A Software which follows all these rules will be a complete RDBMS.
Oracle :- 9 or 10 rules
M.S.Access :- 6 or 7 rules.
Foxpro :- 2 or 3 rules.
Foxpro :- it is one of the leading DBMS software. This is an enhanced and upgrade
version of Dbase III+.
Foxpro is also called RDBMS. We can use foxpro on local area network.
Data Base :- it is an organized collection of related information. Only organized
collection of information will be a database. Any unorganized information cannot be a
database. A database serves an information base and we can use it for :1.

Retrieving desired information

2.

Taking meaningful decision.

3.

Reorganising information.

4.

Processing Information.

A several operation which we need to perform on the database such as adding a new
record, modifying existing information, arranging information in a desired order,
removing unwanted or outdated information etc.
Manual Database :- the manual database has some built in problems :Eg. :- Address Book
Problems :1.

Time consuming.

2.

Difficult to search

3.

Difficult to Modify

4.

It is not easy to arrange information in any alphabetical order.

5.

Managing the database becomes very difficult.

6.

When the database grows in size, it becomes increasingly unmanageable.

These difficulties can be overcome by using a computer to manage the database.


Using a computer database :- computer is more suitable for database application because
of two reasons :1.

Speed :- it operates at a very high speed.

2.

Storage :- it can hold a large amount of data in its storage devices.

It can perform various operations :1.

Searching for a required Information.

2.

Arranging information in alphabetical order.

3.

Calculating results.

*******
Non-Exclusive :- when connected to LAN
Exclusive :- When connected Singly.
Background of Foxpro :- Refrence Window.
Command Window :- Command Window is used for doing various data base operations,
such as creating a database, listing records from the database.
Creating a database file
Computer cannot distinguish information by looking at its contents. Eg. It cannot tell
whether Ashutosh is a name of a person or an address. Therefore, to assist the computer
and Foxpro, before we store the actual information in the database file, we tell foxpro
about the structure of the database file.
The structure define how information is stored in the data base file. i.e. how many fields
are there in a field and what information is stored in each file. The structure also limit the
length of data stored in each field. So to create database file we have to first specify its
structure.
While defining structure we specify the following details :1.

A unique field name for each field i.e. each field must have a name that is not
being used by any other field.

2.

Field Type :- i.e. the type of data such as numeric or character or date to be
stored in each field.

3.

Width :- We have to specify the width of each field for numeric field we have
to specify the number of decimal digit also.

Field Name Limitations


1.

Field Name can be upto 10 characters long.

2.

They must begin with letters (A-Z) and subsequent characters may be letters,
numeral or the underscore character.

3.

Spaces and punctuations marks are not allowed in the field name.

4.

Foxpro does not distinguish between lower and upper case letter in field
name.

Field Type :1.

Character

2.

Numeric

3.

Float

4.

Date

5.

Logical

6.

Memo

7.

General (Foxpro for Windows).

Character :- Character type data can store character A-Z, a to z, 0 to 9 and special
symbols. The character field can have the width of up to 254 characters.
Numeric :- this field can have numeric data thus we can only store digits 0 to 9 decimal
points and + or sign. A numeric field can be upto 20 digits wide. A numeric field can
also have a decimal part. The width of decimal part can be 0 to 18 digits.
Float :- Since Foxpro is generally used for business applications, so float field is not
commonly used.
Date :- Date type is used to store date. The dates are stored in a specific format i.e.
mm/dd/yy. Foxpro always assigns a width of 8 bytes for a date field.

Logical :- Logical field is a special one byte long field i.e. used to store either True (T) or
False (F) in it. Logical fields are particularly useful for storing information that has only
two states.
Memo :-(Ctrl + Home). The memo field is a special field where we can store any amount
of data. This is particularly useful for storing long textual information.
Since a character field cannot be wider than 254 characters, therefore evenif we assign
the maximum field width for any field we can just store 3 to 4 lines of the text. Therefore
we should use the memo field for storing information because there is not limit of size of
data.
The data to be stored in memo field is not stored in .dbf file but in an auxillary file with
the same name but with the extension name .fpt. foxpro allots 10 bytes space in the main
data base file to stored the location of memo data in auxiliary file. If we create a .dbf file
Library with the memo field, foxpro create two files. These are library.dbf the main
database file and the second library.fpt the auxiliary file.
The use of memo field offers many advantages :1.

the memo field occupies 10 bytes of space in a data base record. However we
can store any amount of text for each record.

2.

As an actual data for the memo field is stored in auxiliary data base file, it
helps in reducing the size of main data base file.

3.

Like a character field we can search for information in a memo field with
Locate, find, seek etc.

General :- the general type field is used only for the windows version of foxpro. This
enables us to embed objects created in one windows application within foxpro database.
For e.g. we can use a general field to include a complete spread sheet, a piechart, or even
a word processor document through OLE features of windows. Foxpro even update the
object in the data base when the original object is changed in the other window
application.

COMMANDS
1.

Create :- Creates a new data base file and accepts the structure for it. Optionally

also accepts the data for new dbf file.


Example :-

Create New
Create A:\NewFor Floppy

Note :- By default the extension of define file will be .dbf.


2.

Use Command :- Opens a data base file in a specified workarea. The single use

command can be used to close the current open data base file.
To open a data base file we need to specify a database file name with Use command
Example :3.

Use New.

Modify :- Allows to modify the structure of dbf file open in a current work area.

We can edit field name, its width, its type and also delete and insert field name.
Example :-

Use New
Modify Structure

Note :- We need not write the complete command. We can write only 4 characters for
each command.
To save the structure we use OK or Ctrl+W
4.

Display :- Display the structure of a dbf file open in a current work area. The

structure of the data base file will be displayed as shown below


Structure for database C:\fpw26\New.dbf
No. of records :- 3
Date of last update :Field

Field Name

Type

Width

1.

Name

Character

20

2.

Fname

Character

20

3.

Age

Numeric

Total

Deciman

43

Foxpro shows the name of the dbf file, number of records in it, the data of last update,
field name, type, width, decimal and the total record length.

Important :- Here the total record length is one more than total of records in a dbf file
because a database also store one space for the deletion mark (*).
5.

Quit :- Terminates the current foxpro session and returns to the operating system.

Foxpro closed all open file before returning to the operating system.
6.

Clear :- Foxpro clears the screen but retains the command windows.

7.

Set Default to :- Specifies the default drive and directory for various file read and

write operations. Foxpro uses a current drive and directory for creating and using files,
unless we specify the path. The current drive and directory is one that was used to start
foxpro. So we can set the current working directory as our requirement with the help of
Set Default to command.
Example :-

Set default to a:
Set default to c:\Ashutost.

Note :- the set default to command sets the path temporary. After quiting from the foxpro
we come back to the original foxpro directory. (C;\fpw26\).
We can use separate directory for different application. This will ensure sufficient
housekeeping of files.
8.

Append :- Enables to add records to the end of current data base file.

Append Blank :-Enables to add a blank record at the end of dbf file. Unlike append,
append blank adds only blank records.
It does not open append window but add only one blank records at the end of the file.
Append from :- Adds records to the end of the current data base file from another file.
Example :-

Use New
Append from New1.

This process will append record from New1.dbf at the end of new.dbf. if the two data
base file have the same structure, all the records will be appended. If the structure is
different, than only fields common to both field with data or records and all other
appended fileds will be blank.
Append Memo :- copies the content of a file to a memo field. The append memo
command copies the content of a specific file in a specified memo.
Example :-

Append memo Preface From A.Txt.

This command transfer the content of A.txt file in the preface memo field of the currend
dbf file.
9.

Set carry on/Off :- Determines whether or not foxpro carries data forward from

the current record to the new record created with append.


It is used to carry the last record information to the next new record in the append
window. It is useful when records consist of similar field values.
Set carry to :- Specifies the field from which the field data is carried forward to the new
record.
Example :-

Set carry to New.

Set Bell on/Off :-enables or disables sounding of Bell during editing. It creates a Beep
during the entry of record whenever the limit reached.
Example :12.

Set Bell On.

File Limitation in Foxpro :- When working with foxpro, frequently we have to do

operations such as listing files in a directory, making copy of a dbf file and erasing or
renaming files. Foxpro supports many commands for performing these functions as
describe below :a.

display list of file :- Foxpro supports the following to display the list of

files from the current or specified drive or path.


DIR, DIRECTORY, DISPLAY FILE.
b.

Copy Files :- The copy file command can be used to make a copy of dbf or

other file
Example :- Copy file <Source Path & filename> to <Destination path>
Copy file New.dbf to C:\Fpw26\Ashutosh.dbf.
Note :- To use the copy command to copy a file we need to specify the complete file
name (including file extension name).
c.

Rename :- The Rename command can be used to assign a new name to

any file.
Syntax :- Rename <Old filename> <New filename>
Note :- An opened file cannot be renamed. The complete file name including the
extension name has to be specified.

Erase / Delete file :- The erase command is similar to DOS del command.

This is used to remove the file from the disk.


Syntax :-

Erase Filename or
Delete File Filename.

Note :- At a time we can erase only one file.


13.

Using DOS commands within Foxpro


Run / ! :- Are used to execute any DOS command without quiting Foxpro.
Run Dir/p.

14.

CurDir( ) :- Reutrns the name of current DOS directory.


Example :-

15.

Curdir ( ).

LIST :-Continuously displays all the field of records of current dbf file.
The list command displays all the records on the screen.
Example :-

Use Ashutosh
List
List to Printer.
List Field Name
List Off :- Does not show record No.
List Field, Age, Name <For changing order>
List for age >20 (For finding the age > 20)
List for Name =B or Name = r

16.

Display :- Displays the content of records in the current data base file. The display

command is quite similar to LIST command and is used for the same purpose i.e.
displaying record of the dbf.
The display command only displays the current record unless we specify the number of
records to be displayed.
Display all :- This command is similar to list command. Except that if the record to be
displayed are more than one screen full foxpro will pause after displaying one screen.
Than on pressing any key it displays the next screen. On the other hand list command
displays all the records without any pause.
Display next :- Example :- Display next 4.
Display while :- display while Name =R

17.

Set heading ON/Off :- Determines whether or not column heading are displayed

for fields with command such as list, display etc.


whenever we use list command foxpro shows a field name, before displaying the
actual contents of records. If we want to suppress to display the column heading or field
name we can use this command.
18.

Set Status On/Off :- Displays or removes DOS style status bar. It displays

information such as current drive, data base file, number of records, status of special
keys. It also displays whether the file is opened in exclusive mode or non-exclusive
mode.
19.

Set Status Bar On/Off :- Displays or removes window style status bar.

20.

Set Extract On/Off :- Specifies the rules when comparing string of different

length. When Set Extract is ON the expression must match character for character.
Example :-

List for Name = RAJ (Output :- Raj, Rajesh, Rajkumar etc.)


Set Extract ON
List for Name = RAJ (Output :- Raj).

21.

Delete :- Marks the record for deletion (*) in the active data base file.
Exampl e:-

Use Address
Delete (record No. 1 deleted).
Delete Record 4
Delete all (Deletes all Records)
Delete rest (Delete Record No. after the given Record no.)
Delete For name =Raj.

22.

Recall :- Unmarks specified records marked for deletion.


As delete command does not physically remove, records from the data base file,

so we can get back a deleted record.


Example :-

Use Address
Delete All
Recall all.

23.

Set Delete On :- Specific Whether or not foxpro process records marked for

deletion. When set delete ON, records marked for deletion are not included with
commands such as list copy etc.

example :-

List
* Ashutost.
Set Delete On
It cant display the record of Ashutost.

24.

Pack :- Removes all records mark for deletion and reduces the size of memo file.

After a data base file has been packed deleted record cannot be recall.
The pack command permanently removes deleted records from the database file
and releases the space occupied by the deleted records.
Use Address
Delete all
Pack.
25.

Zap :- Removes all records from the current data base file. This is equivalent to

Delete All followed by Pack. Zapped records cannot be recalled.


Zap = Delete all + Pack.
26.

Deleted :- Returns logical i.e. returns true If the record is marked by * or returns

false if not
example :-

Use Ashutosh
? Deleted
Result (.T.) if deleted.

27.

? = Evaluates the expression and outputs the result in next row.

28.

?? = Evaluates the expression and outputs the result in the same row.

Note :- the ? and ?? commands are used to ask Foxpro to display a particular data on
the screen.
29.

??? :- Sent output directly to the printer.

30.

Go / Go to :- Positions the record pointer on the specified record number in the

active data base file. When we open a data base file foxpro places the cursor on the first
record. Later on when we use other command on the data base file, it moves the record
pointer accordingly. When the database file is small, we can easily use arrow key to move
to the desired record for editing.
However if it contains 100 of records it is quicer to directly select the record
before starting the edit, change or browse commad.

Example :-

Go 3
Go to 3
3
Go to Record 3
All the above given commands are same.

31.

Go top :- Moves the record pointer on the first record in the active data base file.
EOF( ) # Go Bottom
BOF( ) # Go Top

32.

Go Bottom :- Moves the record pointer on the last record in the active data base

file.
33.

Skip :- Moves the record pointer forward or backward in the current or specified

data base file.


Example :-

Go 5
Skip 1 (6)
Skip 5 (11)
Go Bottom (Last Record)
Skip 1 (EOF( ) )
Go Top
Skip 1 (Top of the file or 1 record)

34.

EOF( ) :- determines whether or not a record pointer is positioned past the last

record in the current data base file.


35.

BOF( ) :-

Determines the record pointer is positioned at the beginning of

record of the file.


36.

Replicate( ) :- Returns the characters string that contains a specified character

expression repeated a specified number of time.


Example :-

? Replicate (*,40)
? Replicate (Ram,2) :- Output = Ram, Ram.

37.

RecNO( ) :-

Returns the current record number.

38.

Rec count :-

Returns the number of records in current data base file.

39.

Edit / Change :- Display the specified field of the active data base file for editing.
Example :-

Use Address

Edit (Displays all records).


Edit Record 5 (Display only 5th record).
Note :- We can also add or delete a record from the edit window using a shorcut :For Adding Record :- Ctrl + N
For Deleting Record :- Ctrl + T
40.

Browse :- Opens a browse window and allows editing of screen full of record.
It displays several records in the form of horizontal table.

41.

Locate :- Sequentially searches the data base file for the first record that matches a

specified expression.
Locate is useful command that is used to search for information from the record
of a data base file. Locate searches for the information in the specified field of the data
base file in use.
Example :-

Locate for Name = Raj.


Locate for Age > 20

Locate command will locate only one record at a time from the current position. We
cannot locate another record of the same condition from this command. So to overcome
this problem we use another command Continue with locate command.
42.

Continue :- Continues the previous locate. Tries to locate the next records that

meets the specified conditions.


Note :- Continue command will always be operated after the Locate command.
43.

Replace :- the process of making change with edit and browse command is very

slow. As we need to easily select each record before we can make change. This process
became cumbersome (Difficult) if we have to make a change in several records of a data
base file.
Example :- if we have to reduce the rate of interest on all deposits by 1%. It will
be cumbersome and prone to error. If we manually change the rate of interest in the rate
field using edit or browse command.
Example :-

Replace with rate 1 All


Replace Name with Raj.
Replace Name with Ashutost for Name = Raj.

44.

Insert :- Insert a new record into the current data base file after the current record

and displays it for editing. It can also insert a record before the current record or a blank
record without invoking editing. If we issue insert without the Before or Blank Clause
and edit window is displayed so we can enter the data into the new record. The new
record is placed immediately after the current record.
If SET.CARRY ON and Blank is not included, data in the previous record will be
automatically copied.
45.

Modify command :- Opens a text editing window and allows us to modify or

create a program file. It assumes a default extension name .PRG.


Example :-

Modi Comm Filename.

Foxpro creates a program file By the given filename.


After we have entered the commands in the program file we can save the file by pressing
Ctrl + W.
Program :- A program file contains series of commands. The series of commands that
performs a specific task is called a program.
We have learn several commands and functions. We can use them in a specific sequence
to do a particular job. But, it is cumbersome to repeat some set of steps again and again to
perform a similar kind of task. To overcome this problem we can store the required
commands in a program file. Then whenever we want to repeat these set of commands
we can just ask foxpro to execute the commands stored in a program file.
In brief the program file offers the following advantages :a.

Since all the commands are stored in a file, we do not have to


remember them.

b.

The execution of commands is fast, as no time is wasted between two


commands.

c.

The program entered in a program file can be documented by adding


comments.

d.

There are several powerful commands such as :If Else --- Endif
Dowhile --- Endod

For --- Endfor.


If --- endif
Docase --- Endcase.
Running a Program File :- To executes a command or previous file, we use Do to run
the program. The command contained in the program file are executed until one of the
following occurs :-

46.

a.

Return is encounter.

b.

Cancel is encounter

c.

Another Do is issued.

d.

The end of file is reached.

e.

Quit is executed.

Accepts :- Accept the character string data from the screen


Syntax :- Accept [<Exp>] to [<Memo.Var>]
Example :- Accept Enter Your Name to Name

Accept command display a specific message on the screen and accept the data entered
through keyboard in a character variable i.e. the variable specified with accept command.
Note :- Foxpro always create character variable with accept command.
We do not need to unclosed the data within the quotation mark.
47.

Input :- Input data from the keyboard into memory variable.


Syntax :- Input Enter your age to age.
The input command is slightly modified from the Accept command i.e. unlike

Accept, it displays the specified message on the screen and stores the entered data in the
specified variable. However, unlike Accept, input can create a numeric, Character, logical
and date variable.
The type of variable that input command creates depend upon the keyboard entry and the
de-limiters used to enclose the data.
Example :- Input enter the data to choice.
In response to this command Foxpro displays a message Enter the data on the screen
and waits for data entry. The following table illustrates the type of variable created and
data stored in the variable.
*******

SORTING
Sorting information means to graph, arrange or classify it in some known order. Sorting
helps us in locating the desired information quickly.
Sorting is a method of rearranging or re-ordering list in a particular order (Ascending or
Descending).
One of the most common example of sorting, is found in dictionary. Here thousands of
words are arranged in alphabetic order. Because words are arranged in alphabetically, we
can quickly look for any word within second.
Sort :- Sorts record in the current database file and stores the stored data in a specified
new database file.
Sorting can be done on a single field or combination of two or more fields. The records
can be arranged in the ascending or descending order of the sort field.
When we sort a database file, Foxpro sorts the record as per the specified sort order,
creates another data base file and stores the stored records in a new file.
Since, sort creates another database file, we have to be sure that there is enough disk
space for the new table / .dbf and the temporary work of file created during the sort. The
disk space needed to perform a sort can be as much as three times the size of the source
file. If we run out the disk space during a sort, the alert Not enough disk space is
displayed and the temporary work files are deleted.
A database file can be sorted on character, numeric, float, data and logical fields and any
combination of these fields. However, we cannot sort a file on a memo or general fields.
When Foxpro sorts the data, it follows the ASCII standarts. Accordingly number (0-9)
comes before letters and upper case letters come before lower case letters. Therefore if
we sort a file that contains ANIL and Anil in the name field, Foxpro will place ANIL
before Anil in the sorted records. By default Foxpro sorts the data in the ascending order
and it is case sensitive.
Character type field that contains cumber and spaces may not sort a order we expect.
Numeric field fill from right to left, with empty spaces to the left. In contrast, character
field fill from left to right, with empty spaces to the right.

For Example if two records in a table.dbf contains a character field with 1724 in one
record and 18 in the other, and the table.dbf is sorted on this field in ascending order, the
record containing 1724 appears before the record containing 18. This is because Foxpro
reads each character in the character field from left to right and because 17 in (1724) is
less than 18 it puts 1724 first. To avoid this problem, always precide lower number with
leading zeros (0018) or make the field numeric.
Example :-

Use Ashutosh
Sort on Name to Namelist
Sort on Name to A:\Namelist
Sort on Name to D;\Report\Namelist

Since sorted records are available in Namelist.dbf we need to use this file to see the
sorted recorded.
Use Namelist
List.
Example :-

Selecting Fields in sort file


Use Ashutosh
Sort on Name, To Name1, Fields Name, City

The field Option can also be used to change the order of fields in the sorted database file.
i.e. Sort on Name to Name1 Fields City, Name.
We can specify the fields that appears in the new table by including the like or except
clause or both.
Example :-

Use Ashutost
Sort on Name to xname fields like n*
Sort on Name to Xname fields except city.

Example:-

Sort on Multiple Fields

Sorting can be done on multiple fields whenever requires. For Example we may like to
arrange records as per the city fields and within a particular city the names be arranged
alphabetically. We can use any number of fields in the sort order. Just separating them
with commas and specifying them in the order or importance.
Example :-

Use Ashutosh
Sort on City, Name to Address1

Sort on City, Name to Address2


This sort command arranges records in the order of the city, for each city, it arranges
them according to PIN, and for each PIN, it arranges them as per names.
Example :- Sorting in descending order
Use Ashutosh
Sort on name/D to namelist
Sort on City /D to Namelist.
Ascending / Descending
We can specify a sort order for all sort fields not followed by a /A or /D option. All sort
fields are sorted in ascending order. If we include ascending. All sort fields are sorted in
descending order, if descending is included. The sort field default to an ascending order if
ascending or descending is not included.
i.e.

Use Ashutosh
Sort on City /D, PIN/D, Name/D to Add4
Sort o City,PIN,Name to Add4 Descending.
Sort on City, PIN , Name to Add4 Ascending
Sort on City, PIN, Name to Add4.

Example :- Ignoring case while sorting


Assuming that our address file contains a few names in upper case letter and the rest are
in a mix of upper and lower case letters. If we sort this file, we get undesirable result.
Foxpro will place all uppercase names before upper-lower case names. To overcome this
problems we can ask foxpro to ignore case while sorting.
Use Address
Sort on Name\c To Nocase
Sort on Name\c city\c to Nocase.
Example :-

Sort on descending as well as ignore case


Sort on Name/C, city\DC to Nocase.
Sort on Name\DC city DC to Nocase.

Example :-

Including selected records in sort file :-

We can include selected records in the sort file by using suitable scope and
conditions. The scope clause are ALL, Next <Exp.> Record <Exp.> and Rest.
The Condition can be given using For and While Clauses :i.e.

1
Sort on Name to Add Next 10
10
Sort on Name to Add rest.
Sort on Name to Add rest fields Name, city
Sort on Name to Add next 10 fields Name, City.
Sort on Name to Add 2 For city = New Delhi
10
Sort on Name to Add 5 while city = Delhi
Sort on Name to Add 5 for city = New Delhi
Fields name, city.

Disadvantages of Using Sort


1.

Each sort file requires space on the disk. Typically, the space required for each
file is equal to the size of the original database file.

2.

Sorting is a slow process, computer may take considerable time to sort a large
database file.

3.

The data in sorted file is not automatically updated. Therefore, if we add, edit
or delete even on record in the original file, we need to sort it again. This
becomes cumbersome when the data is modified frequently. Therefore sorting
is practically ruled out in an on-line database (such as ticked reservation),
where data is continuously updated.).

4.

When we use a sort file, the record number change (as compared to original
dbf file). In some situations, particularly in large databases records number to
play an important role.

Inspite of the fact that the data is arranged in the required order, foxpro will still search
for the required information sequentially. For a large database file, it may take
considerable time to locate the required record.

INDEXING
Indexing a database creates an index file. Indexing a database file does not duplicate the
data base file. It just stores the index field and the corresponding record number in the
index file. Therefore the index file is normally smaller than the sort file. The extension of
index file is .idx.
Foxpro can create two types of index files :Single index file.
Compound index file.
Single index file
Using the index command.
Example :-

Use Address
Index on Name to Name 1.

We can create more than one index file for a database file.
Example :-

Use Address
Index on Pin to Pin1.

Now we have two index files


1.

Name1.idx

2.

Pin1.idx

At a time we can use only one of them. If we want to select the other index file, there are
two ways :1.

Open the database file with the desired index file.


Example :-

2.

Use Address Index Name1.idx.

Specify the index file name with Set index to command.


Example :-

Use Address
Set Index to Name1.idx.

Including Selected records in Index file.


Example :-

Use Address.
Index on Name to Name1 for city = Jodhpur.

Removing Duplicate records from index file


If we want to remove duplicate records from index file we have to include the Unique
with index.
Index on Name to Name1 Unique.
Updating single index file
When we make any changes in the data base file. Foxpro can automatically update the
corresponding index file, provided they are active.
Note :- We must keep the all index file active.
Example :-

Use Address
Set Index to Name1, Pin1.

If we want to see records as per any index file we need to select that file with Set order
to command.
Example :-

Use Address
Set Index to name1, Pin1
Set order to pin.

If we do not keep all index files active and modify data in the database we get the
corrupted index file. In that condition we must immediately open all index files and use
Re-index command.
Creating Index files on multiple fields.
Example :-

Use Index
Index on City + Name to cityname.

Notice that the fields have been joined with + rather than which we used in sort
command.
Note :- we cannot join a character field with numeric field.
Compound Index files
A compound index file can hold more than one index files. The extension of compound
index file is .cdx. There are two types of compound index file.
a.

Structured compound index.

b.

Independent compound index file.

The structural compound idx file has the same name as the database file name. These
files are automatically opened by foxpro whenever we open database file.
CIF :- These can have any name accept the dbf name. These files are not automatically
opened with database. We will have to open with some foxpro commands.
To create any CIF we use the keyword TAG. TAG informs foxpro that we want to
create a TAG, not a single idx file.
Example :-

Index on Name tag Name1.

When we not specify any file name, foxpro automatically assign them to the structural
CIF. Which is the same name as original database name with an extension of .Cdx.
We can specify the name of the index Tag with SET ORDER TO command.
Example :-

Use Address
Set Order to City.