FoxPro is a product developed for
managing information or a data stored on the computer in an efficient and
optimum manner. File, which stores data,
is called as a table or database. A systematic approach for managing database
or a collection of databases is provided by a Database Management System
(DBMS), which enables users to access and manipulate information with a minimum
effort. So FoxPro is a Database
Management System (DBMS).
Table: Is
an organized collection of related data.
Record: Is a meaningful way to combine bits and pieces of related
data.
Field: Is
a single item of data which appears in every record in a table.
FoxPro acts as an interface
between user and data stored by the users.
Features
FoxPro offers more than
capability to create and maintain files.
It provides all tools needed to create, maintain and extract data. The features of FoxPro are as:-
- Creating Databases.
- Adding new data to database.
- Editing existing data.
- Removing information from databases.
- Searching & retrieving information from database using a powerful tool called RQBE (Relational Query By
- Example).
- Organizing and viewing database.
- Creating customizing data entry forms by using Screen Builder tool.
- Designing and printing Reports and Creating Labels.
Command Window
Is a FoxPro’s System Window. On selecting FoxPro Command Window
automatically becomes Active Window.
Method of selecting options from Menu is similar to typing FoxPro
commands in the Command Window.
Rules of Entering Field Names
1.
Field Name s can have a maximum of 10 Characters.
2.
It comprises of alphabets A to Z, digits 0 to 9 and an
Underscore( _ ).
3.
No special Characters are Allowed.
4.
Field Name must start with an Alphabet.
Data Types
Character Field:
Used to hold a String of
characters consisting of a Combination of an Alphabet, Number, and Special
Characters. Maximum 254 characters can
be stored in a character field.
Number Field
Stores numbers with or without
decimals. Numbers, minus sign, decimal
point etc are allowed in this field.
Commas can not be entered in this field.
Up to 20 digits can be entered.
Float Field
Is a variation of the numeric
field. It handles numbers with floating
decimal points.
Date Field
Stores date. FoxPro automatically adds slashes after six
digits are entered in the data.
Logical Field
Consist of a single letters
representing true or false value. The
default width is 1 character.
Memo Field
Allows large blocks of text to be
stored in a table and this occupies 10 characters width in a table
structure. Actual contents of memo field
are saved in a separate file.
General Field
Is used to store pictures, sound,
spread-sheets etc. Width of 10
characters is assigned to this field.
Create<File Name>
Creates a file Structure. After this command the system opens a create
table dialog box for us, where we have to specify the field names, field data
type and field width for the same. The
file that is created with this command has an extension .DBF.
Create Student
Opening A Database File (Syntax :- Use<File Name>)
Opens an Existing File.
Use Student
Closing a Database File
Use
Closes the opened File.
Close All
Closes all opened files.
Adding Records in the Database file
Append
Add a new record at the end of
the file. Or reserves an empty record
space for adding a new records, at the end of the database file.
Ctrl+W
Saves as well as closes the file
or any opened window in FoxPro.
Set Commands
Set Commands are used to set
variables FoxPro settings, begins with the keyword SET. The two kinds of Set
Commands are ON or OFF.
Set Status Bar
Enables or disables display of STATUS BAR.
Set Status
ON/OFF.
Set Talk
Turns OFF or ON Screen responses
to most FoxPro operations and calculations within the program.
Set Talk ON/OFF.
Set Confirm
Controls methods of cursor
advance between full screen editing fields.
When Set Confirm is ON, Enter key must be pressed to move the cursor out
of a field, other wise arrow key can also be used.
Set Confirm
ON/OFF
Set Default
Changes the drive or directory as
per user requirement.
Set Default to
C:\Sandhya\.......
Set Default to
D:\Ashu\…..
Directory/Dir
Displays the name of all tables
in the current directory. Number of
records in each file and other information like updation, date, size of bytes
and total number of files and number of bytes free on the disk.
Clear
Clears the screen
Quit
Comes out of the FoxPro
Application.
Operators
Operators are symbols that can be
used in commands to compare date and perform calculations. The operators are as following:
Arithmetic Operators
Performs Numerical
calculations. Arithmetic Operators are
as following:-
( ), **, ^, /,
%, +, -.
Relational Operators
Are used to compare data and
issue a logical result either True or False (T.) or (F.). Only point to be noted is that data on either
side of these operators should be of same data type. The Relational Operators are:
< Less than
> Greater than
> Greater than
= Equal to.
<= Less than Equal to
>= Greater than Equal to
<= Less than Equal to
>= Greater than Equal to
# Not
Equal to
<> Not Equal to
<> Not Equal to
!= Not Equal to
Logical Operators
Compares two expressions and
return logical True or False response.
The logical operators are as follows:
! Not Negation
AND Conjunction
OR Disjunction
Record Pointer
A record pointer is a logical
entity. When a table is first opened,
the record pointer is normally points to the first record in the table. The record on which record pointer is positioned
is called as current record. Commands
for Record Pointer are:-
GO Command
Go command positions record
pointer on specified record number.
Examples:
Go Top, Bottom, <Record
Number>
Go 1… N etc.
Skip Command
Skip command moves record pointer
from its current location. Issuing a
Skip command without <ExpN> advances the record pointer to next
record. If <ExpN> is a positive
number, record pointer move N records ahead. i.e. towards the End Of File. If <ExpN> is a negative number then
record pointer moves N records backwards i.e. towards the beginning of the
file.
Skip 3
Skip -2
?RecNo()
This function returns a value
that is one greater thane the number of records in the file. If the record pointer is positioned beyond
last record in the file, if table is empty, RecNo () returns 1. if record pointer is on the last record skip
moves record pointer to the End Of File (EOF).
? Recno( ).
Modifying Records
Records can be modified by Edit
command. To do that place record pointer
on the record that is to be edited.
Edit <Record No>
Edit 4
If word filed is included in the
command only those fields declared in the <Field List> are
displayed. The fields are displayed in
the order designated in the <Field List>.
Edit field Mark1, Mark2
Set Fields
Designated fields that may be
accessed in a table.
Set Fields ON/OFF
Set Fields to <Field
1><Field 2…><Field N>
To make all fields accessible the
keyword All is used.
Set fields to
All
For clause conditionally displays
records in Edit Window; Filtering out undesired records i.e. Only the records
which satisfy logical condition will be displayed.
Edit for Marks
3>35
Edit for
Dt_Start = {12/12/94}
Edit for City =
“Bombay”
Viewing Records
Data can be viewed with LIST and DISPLAY command in the command window. Syntax:
LIST<ALL/NEXT/RECORD NO>
<FIELD NAME> <FOR CONDITION><TO PRINT>
Default scope of LIST command is
to display all records on the screen.
Scope can be changed by using various options of LIST command the are
as:-
List Record 5
List Roll_No, Course
List Name,
Marks1+marks2+marks3
Using Functions
LIST Command displays all records and positions record pointer at
the end of the file. The End Of File
status can be checked by using EOF().
List
?eof( )
EOF( ) function
This function returns logical
value (.T.) if record pointer is positioned at the end of the Data Base File.
BOF( ) function
This function returns logical
value (.T.) if record pointer is positioned at the beginning of the Data Base
File.
RTRIM ( ) AND TRIM( )
These functions treams off the
trailing blank spaces in a Character Strings.
Syntax:
RTRIM (<Character String>)
TRIM(<Character String>)
Character String to be trimmed
can be specified in function argument as character expression. These functions returns a character string
without trailing blanks.
List RTRIM
(First_Name)+LTRIM (Last_Name)
List RTRIM
(University)+LTRIM(College)
LTRIM ( )
It is used to remove leading
blank spaces in a Character String. Syntax:
LTRIM (<Character String>)
RTRIM(First_Name)
+ LTRIM(LastName)
RTRIM(Scool_Name)
+ LTRIM(University)
Specifying Conditions
Using for clause with list will
display only those records which satisfy the specified condition. Syntax:
LIST for <Field
Name>[<Logical Condition > <Crietaria>
Data can be viewed by using a
Logical Field.
LIST for Mark1
> 75
LIST for Mark1
>=85 AND Course = “Arts”
LIST for RollNo
> 99 OR Course = “Science”
When conditions are given with
for all records are checked for condition irrespective of the pointer
position. Only records which satisfy the
condition are listed. Conditions can
also be specified with while clause.
Syntax:
LIST for RollNo, Course, Mark3
While Mark3 >55
Difference between For and While is that “For” checks all records for the
condition while “While” checks only
from the current record. Conditions with
a FOR condition is terminates when EOF is reached. Whereas conditions with WHILE condition
terminates when a record not satisfy that condition is reached.
Upper ( )
This Function converts all
characters in expression specified as an argument to UPPER case. The function
can also be used to find Character Strings by ignoring its case. Syntax:
UPPER <Character Field>
List for UPPER
(First_Name)= “veena”
Lower( )
It converts Uppercase to lower
case. Syntax:
List for LOWER < Character
Field > = <Criteria>
List for LOWER
(Last_Name) = “SYED”
List for LOWER
(School_Name) = “SARASWATI VIDYALAYA”
Display ( )
Works as LIST command. It shows
only those records that are selected.
Default scope of this command is the current Record. Syntax:
DISPLAY <All/Next x /Record
No) <File Name> <For Condition> <To Print>
DISPLAY all
RollNo, Mark1, Mark2, Mark3, Course
DISPLAY all
RollNo for Course = ‘Science’
DISPLAY all
RollNo, Mark1 for name = “Sandhya"
Set Headings ON/OFF
This determines whether field
names will be displayed above each field in commands like LIST, DISPLAY
etc. By default it is ON. Syntax:
Set HEADING OFF
DISPLAY all
Set Print ON/OFF
It echoes screen output to the
printer in addition to Screen. Syntax:
Set Print ON
Set Alternate ON/OFF
If Output or information
displayed by FoxPro is to be recorded or stored, SET ALTERNATE can be used in
command window. Syntax:
Set ALTERNATE to
list.txt
Set
ALTERNATE ON
List Fields
FirstName, LastName
Set
ALTERNATE OFF
Set Date
Date can be changed by SET DATE
command. By default Date is set in
American Format that is
( MM/DD/YY). We
can set the date as British, Germon, Japan, USA, MDY, DMY, YMD also.
Set CENTURY On/Off
Can be used to display century
with date.
BROWSE Command
Browse mode displays a larger
amount of information at the same time in a tabular form. Records can be edited, changed or modified
and can also be marked for deletion in BROWSE mode.
REPLACE Command
Replace command overwrites
contents of specified fields in a table with new contents. Replace replaces the data that was previously
in <Field 1> with data in <Expr 1>.
By default only one record is replaced.
Syntax:
Replace <Field Name> with
<Criteria>
Replace Mark1
with Mark1 + 15
Replace All
Dt_Start with Date()
Replace All
FirstName with Upper (FirstName)
Replace All
Total with Marks1+Marks2+Marks3
Replace all Avg
with Total /3
SEARCHING Data
Records can be searched by using
a LOCATE, CONTINUE and SEEK COMMANDS.
LOCATE Command
Searches the table for first
record that matches the criteria specified.
LOCATE command operation searches sequentially from TOP to END of the
table until it finds first record that satisfies the criteria. LOCATE command only finds the assuming
record. Syntax:
LOCATE <ALL, NEXT, RECORD,
REST>
LOCATE for
Roll_NO = 132;
DISPLAY
CONTINUE
Can be used to find next
occurrence of condition specified.
DELETE
Used to delete unwanted
records. It is a two step procedure.
- Desired
records are to be marked for deletion.
- Pack
Or physically removing records.
Syntax for delete is :-
Delete [Scope[while
condition][for condition]
DELETE record 2
DELETE All
Set DELETED On.
LIST
To check if records are marked
for deletion use deleted ( ) which returns Logical value.
Go 2.
? Deleted ( )
RECOUNT( )
This Function returns the number
of records in a table.
? RECOUNT ( ).
RECALL Command
Deleted records are normally
visible with their deletion marks. They
can be recalled using RECALL command. Syntax:
RECALL[Scope[While Condition]
[For Condtion].
RECALL next 4
RECALL All
RECALL next 10
for State = “Bombay”
RECALL all for
LNAME = “BOSE” and RollNo >103
PACK Command
All records that are marked for
deletion can be physically removed by pack command.
DELETE All
DELETE FOR NAME
= “Sandhya"
DELETE For
Mark1< 35
PACK
ZAP
Will delete all records from
active table, leaving database structure intact. This don’t provides a way to restore erased
records. Data once deleted will not be
restored back.
Zap
No comments:
Post a Comment