Foxpro: DBMS Stand For Data Base Management System. in This System You Can Create Files, Reports, Labels Etc
Foxpro: DBMS Stand For Data Base Management System. in This System You Can Create Files, Reports, Labels Etc
Foxpro: DBMS Stand For Data Base Management System. in This System You Can Create Files, Reports, Labels Etc
DBMS stand for Data Base Management System. In this system you can create files, reports, labels etc.
The database is the collection of records related to person. The DBMS packages are Dbase III plus, Dbase
IV, FoxBASE, FoxPro etc.
FoxPro is a database management system. It means that using this software we can handle the data
in different way. The activity include in DBMS system are
1] Create a database or format structure to store data.
2] Add records in database.
3] Modify records, Edit records.
4] Search particular records.
5] Arrange records in particular order (ascending or descending order).
6] Delete records
7] Delete Database or modify structure.
8] Prepare Reports and Labels.
The three important terms are
1] Field :- It is the unit or information related to person. Or it is a heading of column in database.
2] Record :- It is the collection of fields or a complete row of table is called record.
3] Database :- The collection of records is called file.
In FoxPro there are different data types are available. These are
1] Character :- Allowed alphabets (A to Z, a to z) number (0 to 9) and special character and space.
2] Numeric :- Allowed digits (0 to 9) and decimal point also contain + or - sign.
3] Float :- Same as Numeric.
4] Date:- the date data type use to define or enter date value.
5] Memo :- The memo data type is same as character data type having unlimited width.
6] General :- it is use for OLE object.
2] Use Command:
This command is use to open an existing file and also to close current file.
Syntax :- Use [File name]
e.g. to open data file
Use Data
3] Append
This command is use to add new records
Syntax
Append [blank]
[from <filename>]
[filed <field list>]
[for <expL>]
e.g.
1] to add records in append window
use data
Append
2] To add blank record without opening append window
append blank
3] To add new records in a current file from file name "student"
append from student
4] To add only though records having city "shegaon" of "student" file
append from student for city = "shegaon"
4] Browse: This command is most popular or useful in FoxPro which let you to add new records, delete
records or modify records in browse window.
Syntax:-
Browse [Scope]
[Fields <fieldlist>]
[For <expL>]
[While<expL>]
[noappend] [nomodify]
[nodelte] [noedit]
e.g
1] To open browse window
Browse
2] To browse only fields Title author and cost only
browse fields Title,Author,Cost
3] To browse only records having cost greater than 300
browse all for cost >300
4] To browse records but not able to add, modify or delete records in browse window
browse all noappend nodelete nomodify
5] List :- this command use to list reocrds on screen, file or to send out put to printer
Syntax:- List [off] [scope]
[field <field list>]
[for<expL>]
[While<expL>]
e.g.
1] To list all records
list
2] To list records without record number
List off
3] To list record only 1 to 3
go top
list next 3
4] To list only fields title and cost
List fields title,cost
5] To list only record of author E. Balguruswami
List all for author="E.balguruswami"
6] To list only title and author of title FoxPro
List fields title, author for title = "FoxPro"
5] Display :- this command use to Display reocrds on screen, file or to send out put to printer
Syntax:-
Display [off] [scope]
[field <field list>]
[for<expL>]
[While<expL>]
e.g.
Display: to display only current record
To Display all records
Display all
8] Pack:- This command is use to delete records permanently marked for delete.
Syntax:- Pack
e.g. delete all record.
use stud & pack
9] Zap:- This command is use to delete all record permanently of currently
open .dbf file.
e.g
To delete all record of data file
use data
zap
10] Go to:- This command lets you to move record pointer in a dbf file.
Syntax:-
e.g
use stud
goto 3
11] Locate :- This command is use to search the record sequentially that matches given expression.
Locate sequentially search the current table for the first record that matches a logical expression. The table
doesn't have to be indexed.
If locate find the record it display it's Record no else place the record pointer to EOF.
Syntax:-
Locate [scope]
For <expL>
[While<expL>]
e.g
To locate records having city shegaon
use stud
Locate all for city = "shegaon"
12] Continue :- Continue command is used after LOCATE succeeds in finding a record, to continue the
LOCATE operation. CONTINUE moves the record pointer to the next record for which the logical
expression specified in the previous LOCATE evaluates to true <.T.>
13] SORT :- Sort command sort the current table and outputs the sorted data to a new table.
Syntax:-
SORT TO <file> ON <field1> [/A | /D] ,
<field2> [/A | /D]
[ascending] [descending]
[scope]
[for <expL>]
[while<expL>]
To sort the current table on field name and store it to temp table but in descending order
Use stud
Sort to temp on name desc
ASCENDING | DESCENDING .cdx files can be built in ascending or descending order. By default
tag are created in ascending order.
e.g
to index file on name in ascending order
use abc
index on name tag a
16] SEEK:- SEEK command is similar to FIND search record in index table. In
this expression is allowed.
e.g.
use lib
index on cost tag a
c=234
seek c
q) SET FILTER TO
Specifies a condition for the current database file. This display only those records which satisfied
the given condition.
e.g.
use stud
set filter to course=”ADCSSAA”
browse
tip:- to remove the filter give command SET FILTER TO ALL
r) SET INDEX TO
Open one or more index files for use with current database file. You can open both .IDX or .CDX
files with this command.
e.g.
use stud
index on name to name
index on rollno to roll
set index to name
s) SET ORDER TO
Select a specified index file or tag as the controlling index file/tag for the current or specified file.
e.g.
use stud
index on name tag name
index on rollno tag roll
set order to name
u) SET RELATION TO
Create the relation with more than one file using this command.
e.g.
suppose the two files are created with name & fields as
emp_c emp_v
code code
name post
dob salary
doj city
tip:- you must remember that you must take one filed comman in both file. Here is code.
Now set the relation as:-
select 1
use emp_c
index on code to code
select 2
use emp_v
index on code to code1
select 1
set relation to code into emp_v
browse fields code,name,emp_v.post,emp_v.salary
w) SET PROCEDURE TO
Opens the procedure file. Only one procedure file is opened at time.
DATE FUNCTIONS
1) DATE():- Returns the current system date, which is controlled by the operating
system.
Syntax & e.g. :-
?DATE( )
Returns date:-
02/14/01
tip:- if century is on then year displayed in yyyy format.
2) DAY() :- Returns the numeric day of the month for a given date expression.
DAY( ) returns a number from 1 through 31.
Syntax :-
DAY(<expD>)
e.g. ?DAY({01/11/99})
Returns value :- 10
5) DOW():- Returns the numeric day of week from given date expression.
The value returned by DOW( ) ranges from 1 (Sunday) through 7 (Saturday).
Syntax:-
DOW(<expD>)
e.g. ?DOW({date())
return value :- 1.
e.g. ?Dow({02/14/2001})
Return value :- 4
6) CDOW():- Return the character day of week from given date expression.
Syntax:-
CDOW(<expD>)
e.g. ?CDOW({02/14/2001})
Return :- Wednesday
7) YEAR():- Return the year from given date expression. SET CENTURY ON/OFF
command will not affect this function it always displayed in YYYY format.
Syntax:-
YEAR(<expD>)
e.g. ?YEAR({01/01/99})
Return:- 1999
11) DMY():- Returns a specified date expression in Day Month Year format.
Syntax:- DMY(<expD>)
e.g. ?DMY({02/10/2001})
Returns:- 10 February 01
Tip:- if SET CENTURY OFF then year displayed in yy format otherwise in YYYY format.
12) MDY():- Returns the specified date expression in Month Day Year format.
Syntax :- MDY(<expD>)
e.g. ?MDY({02/14/2001})
Returns:- February 14, 2001
NUMERIC FUNCTIONS
4) ASIN():- This trigonometric function returns in radians the arc sine of the numeric
expression <expN>.
Syntax :- ASIN(<expN>)
e.g. ?ASIN(-1)
Returns:- -1.57
Tip:-The value of <expN> can range from +1 through -1, and the value returned by ASIN( ) can range from -pi/2
through +pi/2 ( -1.57079 to 1.57079).
5) ATAN():- This trigonometric function returns in radians the arc tangent of a numeric
expression.
Syntax :- ATAN(<expN>)
e.g. ?ATAN(1.3)
Returns:- 0.92
Tip:- the value returned by ATAN( ) can range from -pi/2 through +pi/2 ( -1.57079 to 1.57079). The numeric value
returned by ATAN( ) is in radians.
9) FLOOR():- Returns the nearest integer that is less than or equal to the specified
numeric expression.
Syntax:- FLOOR(<expN>)
e.g:- ?FLOOR(19,90)
Returns:- 19
e.g. ?FLOOR(-19.99)
Return:- -20
TIPS:- FLOOR( ) rounds a positive number with a fractional portion down to the integer portion of the number, and
rounds a negative number with a fractional portion down to the next lowest integer.
10) INT():- Evaluates a numeric expression and returns the integer portion of the
expression.
Syntax :- INT(<expN>)
e.g. :- ?INT(20.99)
Returns:- 19
11) MAX():- Returns the expression with the highest ASCII or numeric value or the
latest date from a list of character, numeric or date expressions.
Syntax :- MAX(<expr1>, <expr2>[, <expr3> ... ])
e.g. ?max(12,22,10)
Returns:- 22
12) MIN():- Returns the expression with the lowest ASCII or numeric value or the
earliest date in a list of character, numeric or date expressions.
Syntax :- MIN(<expr1>, <expr2>[, <expr3> ...])
e.g. ?min(10,9,8)
Returns:- 8
15) SQRT():- Returns the square root of the specified numeric expression.
Syntax :- SQRT(<expN>)
e.g. ?SQRT(121)
Return :- 11
16) VAL():- Returns a numeric expression from a specified character expression
composed of numbers.
Syntax:- VAL(<expC>)
e.g. a=’12’
?VAL(a)
Return:- 12.00
CHARACTER FUNCTIONS
1) ALLTRIM():- Returns the specified character expression with leading and trailing
blanks removed.
Syntax:- ALLTRIM(<expC>)
e.g. ?’”HELLO FRIEND”,ALLTRIM(“ THIS IS TEST “,” example”
Return:- HELLO FRIEND THIS IS TEST example.
Tip:- ALLTRIM( ) removes leading and trailing blanks from the specified character expression and returns the
trimmed expression as a character string.
2) ASC():- Returns the ASCII code for the leftmost character in a character expression.
Syntax :- ASC(<expC>)
e.g. ?ASC(‘a’)
Returns:- 97
Tip:-Every character has a unique ASCII value in the range from 0 to 255.
3) AT():- Returns the beginning numeric position of the first occurrence of a character
expression or field within another character expression or field, counting from the leftmost character.
Syntax:- AT(<expC1>, <expC2>[, <expN>])
Here ,<expC1> - is the character whose position you want to see.
<expC2)- is the text in which you want to search.
<expN>- is the number of occurrence.
e.g.:- ?at(‘A’,’DATA POINT’,2)
Return:- 4
4) CHR():- Returns the character associated with the specified numeric ASCII code.
Syntax :- CHR(<expN>)
e.g. ?CHR(97)
Return:- a
5) ISALPHA():- Returns true (.T.) if the leftmost character in the specified character
expression is an alphabetic character; otherwise, false (.F.) is returned.
Syntax :- ISALPHA(<expC>)
e.g. ?ISALPHA(“12data point”)
Returns:- .F.
7) ISDIGIT():- Returns true (.T.) if the leftmost character of the specified character
expression is a digit (09); otherwise, false (.F.) is returned.
Syntax:- ISDIGIT(<expC>)
e.g. ?ISDIGIT(“12 data “)
Return:- .T.
8) ISLOWER():- Returns true (.T.) if the leftmost character in the specified character
expression is a lower-case alphabetic character.
Syntax :- ISLOWER(<expC>)
e.g. ?ISLOWER(“DATA POIN”)
Return:- .F.
15) RIGHT():- Returns the specified number of rightmost characters from a character
string.
Syntax :- RIGHT(<expC>, <expN>)
e.g. ?RIGHT(“data point”,3)
Return:- int
16) RTRIM():- Returns the specified character expression with all trailing blanks
removed.
Syntax:- RTRIM(<expC>)
e.g. :- ?”HELLO FRIENDS” ,RTRIM(“WEL-COME “),” TO LEARN” FOXPRO””
Return:- HELLO FRIEND WEL-COME TO LEARN
18) SUBSTR():- Returns a specified number of characters from the given character
expression or field.
Syntax:- SUBSTR(<expC>, <expN1>[, <expN2>])
. e.g. ?SUBSTR(“Foxpro is DBMS package”,11,4)
Return:- DBMS
Here, <expC> :- The character expression from which characters are extracted is .
<expN1> :- starting position of character , where character extraction be
begins.
<expN2>:- specifies the number of characters to be extract from the
character expression.
19) TRIM():- Returns the specified character expression with all trailing blanks
removed. TRIM( ) is identical to RTRIM( ).
Syntax:- TRIM(<expC>)
e.g. :- ?"HELLO FRIENDS" ,TRIM("WEL-COME ")," TO LEARN"
Return:- HELLO FRIENDS WEL-COME TO LEARN
12) SCAN…ENDSCAN:- Moves the record pointer through the current table/.DBF and
executes a block of commands for each record that meets the specified conditions.
Syntax:-
SCAN
[<scope>]
[FOR <expL1>]
[WHILE <expL2>]
[<statements>]
[LOOP]
[EXIT]
ENDSCAN
13) DO CASE…. ENDCASE:- Executes the first statement block after DO CASE and
before END CASE whose associated conditional statement evaluates to true (.T.).
Syntax:-
DO CASE
CASE <expL1>
<statements>
[CASE <expL2>
<statements>
...
CASE <expLN>
<statements>]
[OTHERWISE
<statements>]
ENDCASE
16) FOR…ENDFOR:- Executes the commands after FOR and before ENDFOR within
a loop a specified number of times.
Syntax:-
FOR <memvar> = <expN1> TO <expN2> [STEP <expN3>]
<statements>
[EXIT]
[LOOP]
ENDFOR | NEXT
e.g.
FOR mcount = 1 TO 10
? mcount
ENDFOR
19) INPUT:- Inputs data from the keyboard into a system memory variable or an array
element.
Syntax:-
INPUT [<expC>] TO <memvar>
e.g. Input “Enter Number A” To A
?A
22) READ:- Activates objects created with @ ... GET and @ ... EDIT commands.
24) @…GET –(Check Box):- You can create the control buttons. To create check box
you required the numeric variable
Syntax:- @<row>,<col> get mvariable FUNCTION “*C <titleof button>”
e.g. STORE 0 TO CH
@3,4 GET CH FUNCTION “*C ADD”
Return:- ADD
Tip:- you can use PICTURE insteade of FUNCTION like @3,3 get ch PICTURE “@*C ADD” the value of check
box is 1 when it is checked otherwise 0. to define hot key “/<” sign is used before the charcter.
27) @…GET-(Popup):- To create the popup control you need numeric or character
variable. You use ^ symbol as the function code or @^ as picture code.
Syntax:- :- @<row>,<col> get mvariable FUNCTION “^ <title>;<title>;..”
e.g. STORE 0 TO CH
@3,4 GET CH FUNCTION “^Graduate;MBA;BA”
tip:- to activate the check box,radio buttion,popup,push button READ or READ CYCLE
command is used.
30) ON PAD :- Specifies the menu popup or menu bar that is activated when you choose
a specific menu pad.
Syntax:- ON PAD <pad name> OF<menu name1>
[ACTIVATE POPUP <popup name>| ACTIVATE MENU <menu name2>]
31) ON SELECTION PAD :- Specifies a command that execute when you choose a
specific menu bar pad.
Syntax:- ON SELECTION PAD <pad name> OF <menu name>
CREATING LABEL:-
Foxpro provid another facility for desiging & printing the mailing label. The extension of .LBX
To create label format file CREATE LABEL command is used. When you create label you must
open the dbf file for which you create the label.
Steps:-
1. Open the database file as USE EMPLOYEE
2. Then give the command CREATE LABEL EMPL
3. It display the window here the default size is 3 ½” X 15/16” X 2 you can also change it manually.
4. then move the cursor to the WIDTH & give the width .
5. move cursor to Number Across- it menas how many labels placed in one row .
6. move cursor to Space Between – it indicate that how many space left between the labels.
7. move cursor the Lines Between- it indicate that the vertical distance between two label.
8. you can set the height of label.
9. to entered the field expression press ^F it display the box select the field & press ^W.
10. In this way you can add number of fields in label , if you add the self text/prompting then type the text
in “ ” symbol.like "Name:-".
11. Then to see the preview press ^I. To save the label press ^W.
What is TEXT-ENDTEXT?
When you need to display the text use ?/?? instead of this you can use TEXT-ENDTEXT to display
long message. You don’t require to use quotations ,you can type several lines. You can also print the text
on PRINTER.
For e.g.
@2,1 say “Display The menu”
TEXT
1 Add Record
2 Modify Record
3 Delete Record
4 Exit
ENDTEXT
The above command display the matter on screen from text..endtext.