Você está na página 1de 22

FOXPRO

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, FoB!S", Fo#ro etc.
Fo#ro is a database management system. It means that using this soft$are $e can handle the
data in different $ay. The acti%ity include in DBMS system are
&' (reate a database or format structure to store data.
)' !dd records in database.
*' Modify records, "dit records.
+' Search particular records.
,' !rrange records in particular order -ascending or descending order..
/' Delete records
0' Delete Database or modify structure.
1' #repare 2eports and 3abels.
The three important terms are
&' Field :- It is the unit or information related to person. 4r it is a heading of column in database.
)' Record :- It is the collection of fields or a complete ro$ of table is called record.
*' Database :- The collection of records is called file.
1] Creating File in FoxPro
(reate5 To create file in fopro use command (2"!T" command $indo$ $ith file name.
Synta56 Create <filename>
e.g.
Create data
! structure dialog bo appear on screen
7ere enter field names, there datatype -datatype means type of data you all$oed for that field for e.g.
number or character or date. enter $idth of field -space allo$ed. and if necessary enter decimal number.
!fter this select 48 button or press (trl9: to sa%e and eit form structure bo, a message display to
;Input record no$ -y<n.; press y to add records in append $indo$.
!dd some records in append $indo$ and to close and sa%e data in file press (trl 9: again.
Data type a%ailable in Fo#ro
Data type Default $idth Maimum :idth
(haracter &= ),+
>umeric &= )=
Float &= )=
Date =1 =1
3ogical =& =&
Memo &= in dbf file unlimited bytes
?eneral &= in dbf file unlimited bytes
In Fo#ro there are different data types are a%ailable. These are
&' Character :- !llo$ed alphabets -! to @, a to A. number -= to B. and special character and space.
)' Numeric :- !llo$ed digits -= to B. and decimal point also contain 9 or 6 sign.
*' Float :- Same as >umeric.
+' Date:- the date data type use to define or enter date %alue.
,' Memo :- The memo data type is same as character data type ha%ing unlimited $idth.
/' Geeral :- it is use for 43" obCect.
Rules !or ami" !ield
&' Field name must start $ith character or underscore -D. character.
)' Field name can be up to &= char.
*' Space is not allo$ed in field name.
+' Duplicate field name is not allo$ed.
)' Use Command5
This command is use to open an eisting file and also to close current file.
Syta# :- Ese FFile name'
e.g. to open data file
Ese Data
1
$% &pped
This command is use to add ne$ records
Synta
Append [blank]
[from <filename>]
[filed <field list>]
[for <expL>]
e.g.
&' to add records in append $indo$
use data
!ppend
)' To add blank record $ithout opening append $indo$
append blank
*' To add ne$ records in a current file from file name ;student;
append from student
+' To add only though records ha%ing city ;shegaon; of ;student; file
append from student for city G ;shegaon;
+' Bro'se: This command is most popular or useful in Fo#ro $hich let you to add ne$ records, delete
records or modify records in bro$se $indo$.
Syta#:-
Bro$se FScope'
FFields HfieldlistI'
FFor Hep3I'
F:hileHep3I'
Fnoappend' Fnomodify'
Fnodelte' Fnoedit'
e.g
&' To open bro$se $indo$
Bro$se
)' To bro$se only fields Title author and cost only
bro$se fields Title,!uthor,(ost
*' To bro$se only records ha%ing cost greater than *==
bro$se all for cost I*==
+' To bro$se records but not able to add, modify or delete records in bro$se $indo$
bro$se all noappend nodelete nomodify
,' (ist :- this command use to list reocrds on screen, file or to send out put to printer
Syta#:- List [off] [scope]
[field <field list>]
[for<expL>]
[While<expL>]
e.g.
&' To list all records
list
)' To list records $ithout record number
3ist off
*' To list record only & to *
go top
list net *
+' To list only fields title and cost
3ist fields title,cost
,' To list only record of author ". Balgurus$ami
3ist all for authorG;".balgurus$ami;
/' To list only title and author of title Fo#ro
3ist fields title, author for title G ;Fo#ro;
,' Display :- this command use to Display reocrds on screen, file or to send out put to printer
Syta#:-
Display Foff' Fscope'
Ffield Hfield listI'
FforHep3I'
F:hileHep3I'
e.g.
Display5 to display only current record
To Display all records
Display all
To Display records $ithout record number
Display off
To Display record only & to *
go top
Display net *
To Display only fields title and cost
Display fields title,cost
To Display only record of author ". Balgurus$ami
Display all for authorG;".balgurus$ami;
To Display only title and author of title Fo#ro
Display fields title, author for title G JFo#roK
)% Delete : - This command is use to mark records for delete.
Syta#56 Delete Fscope'
Ffield Hfield listI'
FforHep3I'
F:hileHep3I'
e.g.
To Delete all records
Delete all
To Delete record only & to *
go top
Delete net *
To Delete only record of author ". Balgurus$ami
Delete all for authorG;".balgurus$ami;
*% Recall:- This command is use to recall records marked for delete.
Syta# 56 2ecall Fscope'
Ffield Hfield listI'
FforHep3I'
F:hileHep3I'
e+"+
To 2ecall all records
Ese stud
Delete for cityGKShegaonK
2ecall all
To 2ecall record only & to *
Ese stud
Delete all
go top
2ecall net *
To 2ecall only record of author ". Balgurus$ami
3
2ecall all for author G ;".balgurus$ami;
1' Pac,:- This command is use to delete records permanently marked for delete.
Syta#56 #ack
e.g. delete all record.
use stud L pack
B' -ap:- 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
Aap
&=' Go to:- This command lets you to mo%e record pointer in a dbf file.
Syta#:-
e.g
use stud
goto *
&&' (ocate :- This command is use to search the record seMuentially that matches gi%en epression.
3ocate seMuentially search the current table for the first record that matches a logical epression. The
table doesnNt ha%e to be indeed.
If locate find the record it display itNs 2ecord no else place the record pointer to "4F.
Syta#:-
3ocate Fscope'
For Hep3I
F:hileHep3I'
e.g
To locate records ha%ing city shegaon
use stud
3ocate all for city G ;shegaon;
To locate all record bet$een *=== to /===
3ocate all for salary I G *=== .and. salaryHG/===
&)' Cotiue 56 (ontinue command is used after 34(!T" succeeds in finding a record, to continue the
34(!T" operation. (4>TI>E" mo%es the record pointer to the net record for $hich the logical
epression specified in the pre%ious 34(!T" e%aluates to true H.T.I
&*' SOR. 56 Sort command sort the current table and outputs the sorted data to a ne$ table.
Syta#:-
S42T T4 HfileI 4> Hfield&I F<! O <D' ,
Hfield)I F<! O <D'
Fascending' Fdescending'
Fscope'
Ffor Hep3I'
F$hileHep3I'
HfileI $hen a table is sorted a ne$ table is created
HonI Hfield&I you must include a name of a field
F<! O <D' for each field you include in the sort you can specify an ascending or descending sort order.
!S(">DI>? O D"S(">DI>?
Pou can specify a sort order for all sort fields not follo$ed by <! or <D
HscopeI
The scope clauses are5 !ll, >"QT Hep>I, 2"4(2D Hep>I and 2"ST
e.g.
To sort the current table on field name and store it to temp table
Ese stud
Sort to temp on name <a
To sort the current table on field name and store it to temp table but in descending order
Ese stud
Sort to temp on name desc
To sort current table on Title and include only selected fields to it
Ese lib
Sort to abc on title fields title, author, cost
/0% 1de#:- This command is used to arrange the records in ascending or descending order. There are
t$o types of indeing compound indeing -.cd. containing multiple entries called tag and simple inde
-id. containing single inde entry.
Syta#
Inde on Hfield epI
Fto Hid fileI'<Ftag Htag nameI'
Ffor Hep3I'
Fcompact' Fascending O descending'
Hfield epI 5 include fields on $hich you $ant to inde file -not allo$ed different data type fields if u
$ant to use then first con%ert its data type using function..
e.g
use lib
inde on name,dtoc-dofp. tag a additi%e
for Hep3I 4nly records that satisfy the filter epression Hep3I are a%ailable for display and
access.
(ompact create a compact .id file.
!S(">DI>? O D"S(">DI>? .cd files can be built in ascending or descending order. By default
tag are created in ascending order.
e.g
to inde file on name in ascending order
use abc
inde on name tag a
&,' F1ND:- -inde Muery for a single record.
Search an inde table. Find mo%es the record pointer to the first record in the table $hose inde key
matches the character epressing Hep(I.
If the matching record if found 2"(>4-. return itNs record number, F4E>D-. return .T. and "4F-.
return .F.
If S"T >"!2 is 4> and find is unsuccessful, the record pointer is positioned immediately after the
closest matching record.
e.g
use lib
inde on Title tag a additi%e
find ;Fo#ro for :indo$s;
&/' S223:- S""8 command is similar to FI>D search record in inde table. In this epression
is allo$ed.
e.g.
use lib
inde on cost tag a
cG)*+
seek c
&0' S2. COMM&NDS
a. S"T ST!TES 4> O 4FF 5
Display or remo%e Status bar.
b. S"T (34(8 4> O 4FF 5
S"T (34(8 T4 F H24:I ,H(43EM>I'
Determine $eather or not Fo#ro display the system date and specify itNs location. 4n the screen. -total
number on screen is )+ and column is 1= '
e.g.
set clock on
set clock to &),*=
c. S"T (">TE2P 4> O 4FF 5
5
Determine $eather or not Fo#ro displays the century portion of date epression in four digits or t$o
digits.
d. S"T B"33 4> O 4FF
Turn the computer bell on or off and set the bell attributes.
synta
S"T B"33 4> O 4FF
S"T B"33 FHfreMuencyI,HdurationI'
FreMuency is bet$een &B to &==== hertA
!nd duration is bet$een & to &B
e.g.
S"T B"33 4>
S"T B"33 T4 &)=== , &)
e. S"T D"3"T"D 4> O4F
Specify $eather or not fopro processes records marked for deletion 4r a%ailable for use in other
commands
f. S"T T!38 4> O 4FF
Determine $eather or not fopro display command reasult
g. S"T "S(!#" 4> O 4FF
Determine $eather or not pressing the "scape key interrupts program and command eecution.

h. S"T 7"!DI>? 4> O 4FF
Set 7eading specifies $eather a field name is displayed as a column heading output of a%erage,
calculate, display, list and sum.
i. S"T >"!2 4> O 4FF
Determine $eather the record pointer is positioned after FI>D or S""8 unsuccessfully search for a
record.
C. S"T S!F"TP 4> O 4FF
Determines $eather or not Fo#ro display a $arning before o%er$riting an eisting file.
k. S"T "Q!(T 4> O 4FF
Specifies rules used $hen comparing strings of different lengths.
l. S"T D!T" FT4' !M"2I(!> O!>SI O
B2ITIS7 O F2">(7 O ?"2M!>
O IT!3I!> O R!#!> O ES! O MDP
O DMP O PMD
Ese this command to set the format used to display date epressions. 7ere are the settings and the
resulting date epressions.
2esulting date format
Setting Format
!merican mm<dd<yy
!nsi yy.mm.dd
Italian dd6mm6yy
?erman dd.mm.yy
British < French dd<mm<yy
Rapan yy<mm<dd
Esa mm6dd6yy
Mdy mm6dd6yy
Dmy dd6mm6yy
Pmd yy<mm<dd
S"T D"(IM!3 T4 Hep>I
Specify the decimal places display in numeric used to display the result of di%ision, multiplication and
trigonometric and financial function.
e.g.
set decimal to )
m. S"T (!22P 4><4FF
Determine $hether or not fopro carry for$ord the entired record from current record created
by !##">D command.
n. S"T (!22P T4 HfieldI
Specifies the fields from $hich you $ant to carry for$ord the data to the ne$ record.
e.g.
use stud
set carry to city,course
append
o. S"T (4>FI2M 4><4FF
Specifies $hether or not enter or tab key pressed to eit an input field and mo%e to the net field.
By default confirm is OFF
p. S"T D"F!E3T T4 HpathI
Species the default dri%e L directory for $orking .
e.g.
set default to a!main
M. S"T FI3T"2 T4
Specifies a condition for the current database file. This display only those records $hich satisfied
the gi%en condition.
e.g.
use stud
set filter to course"#A$C%%AA#
bro&se
tip' to remo(e the filter )i(e command %*+ F,L+*- +O ALL
r. S"T I>D"Q T4
4pen one or more inde files for use $ith current database file. Pou can open both .IDQ or .(DQ
files $ith this command.
e.g.
use stud
inde on name to name
inde on rollno to roll
set inde to name
s. S"T 42D"2 T4
Select a specified inde file or tag as the controlling inde file<tag for the current or specified
file.
e.g.
use stud
index on name ta) name
index on rollno ta) roll
set order to name
t. S"T M"SS!?" T4 Hep>I
Specifies the message to ro$ location created by user.
u. S"T 2"3!TI4> T4
(reate the relation $ith more than one file using this command.
e.g.
suppose the t$o files are created $ith name L fields as
empDc empD%
code code
name post
dob salary
doC city
tip' .ou must remember that .ou must take one filed comman in both file/ 0ere is code.
>o$ set the relation as56
7
select 1
use emp2c
index on code to code
select 3
use emp2(
index on code to code1
select 1
set relation to code into emp2(
bro&se fields code4name4emp2(/post4emp2(/salar.
%. S"T E>ISE" 4><4FF
Specifies $eather or not the duplicat record are displayed or not in index file/
$. S"T #24("DE2" T4
4pens the procedure file. 4nly one procedure file is opened at time.
D&.2 F4NC.1ONS
&. D&.256:- 2eturns the current system date, $hich is controlled by the operating
system.
Syta# 7 e+"+ :-
5$A+*6 7
2eturns date56
=)<&+<=&
tip' if centur. is on then .ear displa.ed in .... format/
86 D&956 :- 2eturns the numeric day of the month for a gi%en date epression.
D!P- . returns a number from & through *&.
Syta# :-
$A86<exp$>7
e.g. TD!P-U=&<&&<BBV.
2eturns %alue 56 &=
$6 MON.:56:- 2eturn the numeric month of gi%en date epression.
Syta#:-
9onth6<exp$>7
e.g.
TM4>T7-U&=<=B<&BBBV.
2eturn %alue 56 &=
06 CMON.:56:- 2eturn the character month of gi%en date epression.
Syta#:-
C9O:+06<exp$>7
e.g. T(M4>T7-U=B<=*<0BV.
2eturn %alue56 September
+ip ' .ou can also &rite the character text to this date as
TWMy birth day $ill come in the month ofW,cmonth-U=B<=*<&B0BV.
-eturn ' 9. birth da. &ill come in the month of %eptember
;6 DO<56:- 2eturns the numeric day of $eek from gi%en date epression.
The %alue returned by D4:- . ranges from & -Sunday. through 0 -Saturday..
Syta#:-
$OW6<exp$>7
e.g. TD4:-Udate-..
return %alue 56 &.
e.g. TDo$-U=)<&+<)==&V.
2eturn %alue 56 +
)6 CDO<56:- 2eturn the character day of $eek from gi%en date epression.
Syta#:-
C$OW6<exp$>.
e.g. T(D4:-U=)<&+<)==&V.
2eturn 56 :ednesday
*6 92&R56:- 2eturn the year from gi%en date epression. S"T (">TE2P 4><4FF
command $ill not affect this function it al$ays displayed in 8888 format.
Syta#:-
8*A-6<exp$>7
e.g. TP"!2-U=&<=&<BBV.
2eturn56 &BBB
1. C.OD56:- 2eturn the a character epression to a date epression.
Syta#:-
C+O$6<expC>7
e.g.. T(T4D-J&=<=&<&BBBK.
2eturns56 &=<=&<&BBB
+ip' C+O$6 74 the character to date function4 returns a date t.pe (alue from a character expression/
B. D.OC56:- (on%ert the date epression into character epression.
Syta#:- $+OC6<exp$>7
e.g. TDT4(-U&=<=&<&BBBV.
2eturn 56 &=<=&<&BBB
&=. D.OS56:- 2eturns a character6string date in the format PPPPMMDD from a
specified date epression.
Syta#:- $+O%6<exp$>7
e.g. TDT4S-U&=<=B<&BBBV.
2eturns56 &BBB&==B
&&. DM956:- 2eturns a specified date epression in Day Month Pear format.
Syta#:- $986<exp$>7
e.g. TDMP-U=)<&=<)==&V.
2eturns56 &= February =&
+ip' if %*+ C*:+U-8 OFF then .ear displa.ed in .. format other&ise in 8888 format/
&). MD956:- 2eturns the specified date epression in Month Day Pear format.
Syta# :- 9$86<exp$>7
e.g. TMDP-U=)<&+<)==&V.
2eturns56 February &+, )==&
N4M2R1C F4NC.1ONS
&. MOD56:- 2eturns the remainder obtained by di%iding a numeric epression by another
numeric epression.
Syta# :- 9O$6<exp:1> 4 <exp:3>
e.g. TM4D-&=,*
2eturn 56 &
+ip' 9O$ is identical to ;
). &BS56:- 2eturns the absolute %alue of the specified numeric epression.
Syta# :- A<%6<exp:>7
e.g. T!BS-6&)B.B=.
2eturns5 &)B.B=
*. &COS56:- 2eturns the arc cosine of a specified numeric epression in radian.
Syta# :- ACO%6<exp:>7
e.g. T!(4S-=.&=.
2eturns56 &.+0
+ip' +he (alue of <exp:> can ran)e from =1 throu)h '1/+he (alue returned b. ACO%6 7 ran)es from > throu)h
pi 6 ?/1@1AB37/
+. &S1N56:- This trigonometric function returns in radians the arc sine of the numeric
epression Hep>I.
Syta# :- A%,:6<exp:>7
e.g. T!SI>-6&.
2eturns56 6&.,0
+ip'+he (alue of <exp:> can ran)e from =1 throu)h '14 and the (alue returned b. A%,:6 7 can ran)e from 'piC3
throu)h =piC3 6 '1/AD>DB to 1/AD>DB7/

,. &.&N56:- This trigonometric function returns in radians the arc tangent of a numeric
epression.
Syta# 56 A+A:6<exp:>7
e.g. T!T!>-&.*.
9
2eturns56 =.B)
+ip' the (alue returned b. A+A:6 7 can ran)e from 'piC3 throu)h =piC3 6 '1/AD>DB to 1/AD>DB7/ +he numeric
(alue returned b. A+A:6 7 is in radians/
/. COS56:- 2eturns the cosine of a numeric epression.
Syta#:- CO%6<exp:>7
e.g. Tcos-+,.
2eturns.,*
+ip'the (alue returned b. CO%6 7 ran)es bet&een '1 and 1/ <exp:> is )i(en in radians/
D7 D.OR56:- (on%erts the %alue of a numeric epression gi%en in degrees to an
eMui%alent %alue in radians.
Syta# :- $+O-6<exp:>7
e.g. TDT42-&1=.
2eturns56 *.&+
1. 2XP56 :- 2eturns the %alue of eX $here is a specified numeric epression.
The %alue of e, the base of natural logarithms, is approimately ).0&1)1.
Syta#:- *EF6<exp:>7
e.g. T"Q#-).
2eturns56 0.*B
=6 F(OOR56:- 2eturns the nearest integer that is less than or eMual to the specified
numeric epression.
Syta#:- FLOO-6<exp:>7
e.g56 TF3442-&B,B=.
2eturns56 &B
e.g. TF3442-6&B.BB.
2eturn56 6)=
+,F%' FLOO-6 7 rounds a positi(e number &ith a fractional portion do&n to the inte)er portion of the number4
and rounds a ne)ati(e number &ith a fractional portion do&n to the next lo&est inte)er/
/>6 1N.56:- "%aluates a numeric epression and returns the integer portion of the
epression.
Syta# :- ,:+6<exp:>7
e.g. 56 TI>T-)=.BB.
2eturns56 &B
//6 M&X56:- 2eturns the epression $ith the highest !S(II or numeric %alue or the
latest date from a list of character, numeric or date epressions.
Syta# :- 9AE6<expr1>4 <expr3>[4 <expr?> /// ]7
e.g. Tma-&),)),&=.
2eturns56 ))
/86 M1N56:- 2eturns the epression $ith the lo$est !S(II or numeric %alue or the
earliest date in a list of character, numeric or date epressions.
Syta# :- 9,:6<expr1>4 <expr3>[4 <expr?> ///]7
e.g. Tmin-&=,B,1.
2eturns56 1
/$6 RO4ND56:- 2eturn a numeric epression rounded to a specified number of decimal
places.
Syta#:- -OU:$6<exp:1>4 <exp:3>7
e.g. T24E>D-&B.BB,/,).
2eturn56 )=.==
+ip ' if the number is )reater than A4 then 1 is added to the pre(ious number/
/06 R.OD56:- (on%erts a numeric epression that represents radians to an eMui%alent
%alue in degrees.
Syta# :- -+O$6<exp:>7
e.g. T2T4D-*.&+&/.
2eturns56 &1=.==
&,. S?R.56:- 2eturns the sMuare root of the specified numeric epression.
Syta# :- %G-+6<exp:>7
e.g. TSS2T-&)&.
2eturn 56 &&
/)6 @&(56:- 2eturns a numeric epression from a specified character epression
composed of numbers.
Syta#:- HAL6<expC>7
e.g. aGW&)W
TV!3-a.
2eturn56 &).==
C:&R&C.2R F4NC.1ONS
&. &((.R1M56:- 2eturns the specified character epression $ith leading and trailing
blanks remo%ed.
Syta#:- ALL+-,96<expC>7
e.g. TWK7"334 F2I">DK,!33T2IM-J T7IS IS T"ST J,K eampleK
2eturn56 7"334 F2I">D T7IS IS T"ST eample.
+ip' ALL+-,96 7 remo(es leadin) and trailin) blanks from the specified character expression and returns the
trimmed expression as a character strin)/
). &SC56:- 2eturns the !S(II code for the leftmost character in a character epression.
Syta# :- A%C6<expC>7
e.g. T!S(-YaW.
2eturns56 B0
+ip'*(er. character has a uniIue A%C,, (alue in the ran)e from > to 3AA/
*. &.56:- 2eturns the beginning numeric position of the first occurrence of a character
epression or field $ithin another character epression or field, counting from the leftmost character.
Syta#:- A+6<expC1>4 <expC3>[4 <exp:>]7
7ere ,Hep(&I 6 is the character $hose position you $ant to see.
Hep().6 is the tet in $hich you $ant to search.
Hep>I6 is the number of occurrence.
e.g.56 Tat-Y!W,WD!T! #4I>TW,).
2eturn56 +
+. C:R56:- 2eturns the character associated $ith the specified numeric !S(II code.
Syta# :- C0-6<exp:>7
e.g. T(72-B0.
2eturn56 a
,. 1S&(P:&56:- 2eturns true -.T.. if the leftmost character in the specified character
epression is an alphabetic characterZ other$ise, false -.F.. is returned.
Syta# :- ,%ALF0A6<expC>7
e.g. TIS!3#7!-J&)data pointK.
2eturns56 .F.
*6 1SD1G1.56:- 2eturns true -.T.. if the leftmost character of the specified character
epression is a digit -=B.Z other$ise, false -.F.. is returned.
Syta#:- ,%$,J,+6<expC>7
e.g. TISDI?IT-J&) data J.
2eturn56 .T.
1. 1S(O<2R56:- 2eturns true -.T.. if the leftmost character in the specified character
epression is a lo$er6case alphabetic character.
Syta# :- ,%LOW*-6<expC>7
e.g. TIS34:"2-JD!T! #4I>K.
2eturn56 .F.
=6 1S4PP2R56:- 2eturns true -.T.. if the first character in a character epression is an
upper6case alphabetic character.
Syta#:- ,%UFF*-6<expC>7
e.g. TISE##"2-JD!T! #4I>TK.
2eturn56 .T.
/>6 (2F.56:- 2eturns a specified number of characters from a character epression,
starting $ith the leftmost character.
Syta#:- L*F+6<expC>4 <exp:>7
e.g. T3"FT-J data pointK,*.
2eturn56 dat
//6 (2N56:- 2eturns the number of characters in a character epression.
Syta# :- L*:6<expC>7
e.g. T3">-Jdata pointK.
11
2eturn56 &=
/86 (O<2R56:- 2eturns a specified character epression in lo$er6case letters.
Syta# :- LOW*-6<expC>7
e.g. T34:"2-JD!T! #4I>TK.
2eturn56 data point
/$6 (.R1M56:- 2eturns the specified character epression $ith leading blanks remo%ed.
Syta# :- L+-,96<expC>7
e.g. TWFo#ro programming is easyY,3T2IM-J friendsK.
2eturn56 Fo#ro programming is easy friendsK.
/06 R2P(1C&.256:- 2epeat the character epression at gi%en number.
Syta# :- -*FL,CA+*6<expC>4 <exp:>7
e.g. T2"#3I(!T"-Y[W,+.
2eturn56 [[[[
/;6 R1G:.56:- 2eturns the specified number of rightmost characters from a character
string.
Syta# :- -,J0+6<expC>4 <exp:>7
e.g. T2I?7T-Jdata pointK,*.
2eturn56 int
/)6 R.R1M56:- 2eturns the specified character epression $ith all trailing blanks
remo%ed.
Syta#:- -+-,96<expC>7
e.g. 56 TK7"334 F2I">DSK ,2T2IM-J:"36(4M" J.,K T4 3"!2>K F4Q#24KK
2eturn56 7"334 F2I">D :"36(4M" T4 3"!2>
/*6 S.4FF56:- 2eturns a character string by replacing a specified number of characters
in a character epression $ith another character epression.
Syta# :- %+UFF6<expC1>4 <exp:1>4 <exp:3>4 <expC3>7
e.g. TSTEFF-JI ha%e a bigger elephantK,&=,/,KbigK.
2eturn56 I ha%e a big elephant
7ere, <expC1>' Is the string in $hich you $ant to replace the character.
<exp:1>' is the starting position of tet.
<exp:3>' is the number of character upto $hich you $ant to replace the
character.
<expC3>' is the ne$ tet $hich you $ant to put in string.
/A6 S4BS.R56:- 2eturns a specified number of characters from the gi%en character
epression or field.
Syta#:- %U<%+-6<expC>4 <exp:1>[4 <exp:3>]7
. e.g. TSEBST2-JFopro is DBMS packageK,&&,+.
2eturn56 DBMS
7ere, <expC> ' The character epression from $hich characters are etracted is .
<exp:1> ' starting position of character , $here character etraction be
begins.
<exp:3>' specifies the number of characters to be etract from the
character epression.
/=6 .R1M56:- 2eturns the specified character epression $ith all trailing blanks
remo%ed. T2IM- . is identical to 2T2IM- ..
Syta#:- +-,96<expC>7
e.g. 56 T;7"334 F2I">DS; ,T2IM-;:"36(4M" ;.,; T4 3"!2>;
2eturn56 7"334 F2I">DS :"36(4M" T4 3"!2>
8>6 4PP2R56:- 2eturns the specified character epression in upper6case.
Syta#:- UFF*-6<expC>7
e.g. 56 TE##"2-Jdata pointK.
2eturn56 D!T! #4I>T
F1(2 M&N1P4(&.1ON COMM&NDS
&. COP9 .O :- (opies the contents of the current table<.DBF to a ne$ file.
Syta#:-
COF8 +O <file>
[F,*L$% <field list>]
[<scope>]
[FO- <expL1>]
[W0,L* <expL3>]
[+8F*][ WK1 L WK% L W-1 L W-K L EL% L
e.g.
(opy only those records $hich ha%e city as %0*JAO: and salar. >?>>>
U%* *9F
COF8 +O E8M FO- C,+8"#%0*JAO:# A:$ %ALA-8>"?>>>
(opy only fields name,city,dob,course
U%* %+U$
COF8 +O E8M F,*L$% :A9*4C,+84$O<4COU-%*
). COP9 S.R4C.4R2 :- (opies the structure of the current table<.DBF to a ne$
table<.DBF.
Syta#:-
COF8 %+-UC+U-* +O <file>
[F,*L$% <field list>]
e.g.
(opy entire structure to yA
U%* %+U$
COF8 %+-UC+U-* +O E8M
(opy only fields name,dob,course
U%* %+U$
COF8 %+-UC+U-* +O E8M F,*L$% :A9*4$O<4COU-%*
.
*. COP9 F1(2:- (reate a duplicate file of any file.
Syta#:-
COF8 F,L* <file1> +O <file3>
e.g.
(opy the %tud/Fr) file into %tudent/Fr)
COF8 F,L* %+U$/F-J +O %+U$*:+/F-J
(opy E.N/$bf into E.N1/$bf
COF8 F,L* E8M/$<F +O E8MO/$<F
+ip' &hen $<F file &ill cop. the file must be closed/
+. R2N&M2:- (hange the name of original file into ne$ name.
Syta#:-
-*:A9* <file1> +O <file3>
e.g. (hange the name E.N/$bf to Abc/$bf
-*:A9* E8M/$<F +O A<C/$<F
,. CR2&.2 R2POR.:- 4pens a report in a 2eport Design $indo$.
Syta#:- C-*A+* -*FO-+ <filename>
e+g. C-*A+* -*FO-+ E8M
tips' +he extension of report file is .FRX +O open report file 9O$,F8
-*FO-+ command is used/
/. CR2&.2 (&B2(:- 4pens a 3abel Design $indo$ in Fo#ro for MS6D4S. 4r
4pens the >e$ 3abel dialog in Fo#ro for :indo$s.
Syta#:-
C-*A+* LA<*L [<file>]
e.g. C-*A+* LA<*L %+U$*:+
tip ' the extension of LA<*L file is .LBX. +o Open the label 9O$,F8 LA<*L command
is used/
0. CR2&.2 SCR22N:- 4pens a Screen Design $indo$.
Syta#:-
C-*A+* %C-**: [<file>]
e.g. C-*A+* %C-**: E8M
tip' the extension of screen is .SCX/ +o opend screen file 9O$,F8 %C-**: command
13
is used/
1. D2F1N2 <1NDO<:- (reates a $indo$ and specifies its attributes.
Syta#:-
$*F,:* W,:$OW <&indo& name1> F-O9 <ro&14 column1> +O <ro&34 column3> L A+
<ro&?4 column?> %,M* <ro&@4 column@>
[FO:+ <expC1>[4 <exp:1>]]
[%+8L* <expC3>]
[FOO+*- <expC?>]
[+,+L* <expC@>]
[$OU<L* L FA:*L ]
[F,LL <expCP> L F,LL F,L* <bmp file>]
e.g. $*F,:* W,:$OW output F-O9 341 +O 1?4DA +,+L* QOutputQ R
CLO%* FLOA+ J-OW %0A$OW MOO9
AC+,HA+* W,:$OW output
WA,+ W,:$OW Qpress an. ke. to hide &indo& outputQ
0,$* W,:$OW output
WA,+ W,:$OW Qpress an. ke. to sho& &indo& outputQ
%0OW W,:$OW output
WA,+ W,:$OW Qpress an. ke. to release &indo& outputQ
-*L*A%* W,:$OW output
B. &C.1@&.2 <1NDO<:- Displays and acti%ates one or more user6defined $indo$s
or Fo#ro system $indo$s.
Syta#:- !(TIV!T" :I>D4: FH$indo$ name&IF, H$indo$ name)I ...'' O !33
&=. D2&C.1@2 <1NDO< :- Deacti%ates specific user6defined $indo$s or Fo#ro
system $indo$s and remo%es them from the screen but not from memory.
Syta#:-
$*AC+,HA+* W,:$OW <&indo& name1>[4 <&indo& name3> ///] L ALL]
&&. D2(2.2 F1(2:- Delete any file from memory.
Syta#:- $*L*+* F,L*<filename>
e/)/' D"3"T" FI3" QP@.DBF
tip' When .ou delete the databaseC/dbf file the file must be closed/ S .ou must specif. the
extension of file/
&). SC&NB2NDSC&N:- Mo%es the record pointer through the current table<.DBF and
eecutes a block of commands for each record that meets the specified conditions.
Syta#56
%CA:
[<scope>]
[FO- <expL1>]
[W0,L* <expL3>]
[<statements>]
[LOOF]
[*E,+]
*:$%CA:
&*. DO C&S2B+ 2NDC&S2:- "ecutes the first statement block after D4 (!S" and
before ">D (!S" $hose associated conditional statement e%aluates to true -.T...
Syta#:-
$O CA%*
CA%* <expL1>
<statements>
[CA%* <expL3>
<statements>
///
CA%* <expL:>
<statements>]
[O+0*-W,%*
<statements>]
*:$CA%*
&+. DO <:1(2B2NDDO:- "ecutes a block of statements $ithin a conditional loop.
Syta#56
$O W0,L* <expL>
<statements>
[LOOF]
[*E,+]
*:$$O
&,. 2X1.:- "its a D4 :7I3", F42 or S(!> loop.
Syta#:-
*E,+
&/. FORB2NDFOR:- "ecutes the commands after F42 and before ">DF42 $ithin
a loop a specified number of times.
Syta#:-
FO- <mem(ar> " <exp:1> +O <exp:3> [%+*F <exp:?>]
<statements>
[*E,+]
[LOOF]
*:$FO- L :*E+
e.g.
F42 mcount G & T4 &=
T mcount
">DF42
&0. 1FB2ND1F:- It is (onditional statement $hich eecutes a set of commands based
on the logical epression.
Syta#:-
,F <expL>
<statements>
[*L%*
<statements>]
*:$,F
e.g.
(34S" D!T!B!S"S
ES" customer
34(!T" F42 cityGK!843!K
IF F4E>D- .
T N(ompany5 N 9 company
"3S"
T N(ondition N 9 temp 9 N $as not found N
">DIF
ES"
&1. FO4ND56:- 2eturns true if (4>TI>E", FI>D, 34(!T" or S""8 is successful.
Syta#:-
FOU:$6[<exp:> L <expC>]7
e.g. ES" STED
ST42" = T4 mcount
34(!T" F42 (4E2S" G N!D(SS!!N
D4 :7I3" F4E>D- .
mcount G mcount 9 &
(4>TI>E"
">DD4
:!IT :I>D4: NTotal student form !D(SS!! course5 N Z
9 3T2IM-ST2-mcount.. >4:!IT
&B. 1NP4.:- Inputs data from the keyboard into a system memory %ariable or an array
element.
Syta#:-
,:FU+ [<expC>] +O <mem(ar>
e.g. Input J"nter >umber !K To !
T!
)=. &CC2P.:- !ccepts character string data from the screen.
Syta#:-
ACC*F+ [<expC>] +O <mem(ar>
e.g. !ccept J"nter the name56J to name
)&. CB G2.:- (reates an editing region.
Syta#:-
15
T <ro&4 column> J*+ <mem(ar> L <field>
[FU:C+,O: <expC1>]
[F,C+U-* <expC3>]
[FO:+ <expC?>[4 <exp:1>]]
[%+8L* <expC@>]
e.g. T1343 )et name pictur UTO# font Uarial#41P st.le U<,#
read
)). R2&D:- !cti%ates obCects created $ith \ ... ?"T and \ ... "DIT commands.
)*. CB S&9:- Displays output at a specified ro$ and column position.
Syta#:-
T <ro&4 column> %A8 <expr>
[FU:C+,O: <expC1>]
[F,C+U-* <expC3>]
[%,M* <exp:1>4 <exp:3>]
[FO:+ <expC?>[4 <exp:?]]
[%+8L* <expC@>]
e.g. \&),) say J:"36(4M" T4 D!T! #4I>TK style JBIK
)+. CBG2. D5Chec, Bo#6:- Pou can create the control buttons. To create check bo
you reMuired the numeric %ariable
Syta#:- T<ro&>4<col> )et m(ariable FU:C+,O: UVC <titleof button>#
e.g. ST42" = T4 (7
\*,+ ?"T (7 FE>(TI4> J[( !DDK
2eturn56 !DD
+ip' .ou can use F,C+U-* insteade of FU:C+,O: like T?4? )et ch F,C+U-* UTVC A$$# the value of check
ox i! 1 "hen it i! checked other"i!e #. to define hot ke. U$%# si)n is used before the charcter/
),. CBG2.-5Radio butto6:- 2adio button reMuired numeric or character %ariable.
Syta#:- T<ro&>4<col> )et m(ariable FU:C+,O: UV-<title>R<title>R//#
e.g. ST42" = T4 (7
\*,+ ?"T (7 FE>(TI4> J[2 ]H!DDZD]H"3"T"K
2eturn56 - . !DD
- . D"3"T"
)/. CBG2.-5Push Butt+6:- Same as radio button .
Syta#:- T<ro&>4<col> )et m(ariable FU:C+,O: UV-<title>R<title>R//#
e.g. ST42" = T4 (7
\*,+ ?"T (7 FE>(TI4> J[ 48Z(!>("3K
2eturn56 H48 I
H(!>("3I
tip' ,f the button &ants to displa. horiNontall. the use 0 &ith V like
\*,+ ?"T (7 FE>(TI4> J[ 7 48Z(!>("3K it display like H48I H(!>("3I
by default it is %aritically placed.
)0. CBG2.-5Popup656 To create the popup control you need numeric or character
%ariable. Pou use E symbol as the function code or CE as picture code.
Syta#:- :- T<ro&>4<col> )et m(ariable FU:C+,O: UW <title>R<title>R//#
e.g. ST42" = T4 (7
\*,+ ?"T (7 FE>(TI4> JX?raduateZMB!ZB!K
tip' to acti(ate the check box4radio buttion4popup4push button -*A$ or -*A$ C8CL*
command is used/
)1. D2F1N2 M2N4:- (reate a menu bar.
Syta#:- $*F,:* 9*:U <menu name>
[<A- [A+ L,:* <exp:1>]]
[,: [W,:$OW] <&indo& name>]
)B. D2F1N2 P&D : create a pad on a user define bar .
Syta#:- $*F,:* FA$ <pad name> OF <menu name> F-O9F+ <expC1>
[A+ <ro&>4<col>]
[K*8 <ke. label>]
*=. ON P&D :- Specifies the menu popup or menu bar that is acti%ated $hen you choose
a specific menu pad.
Syta#:- O: FA$ <pad name> OF<menu name1>
[AC+,HA+* FOFUF <popup name>L AC+,HA+* 9*:U <menu name3>]
*&. ON S2(2C.1ON P&D :- Specifies a command that eecute $hen you choose a
specific menu bar pad.
Syta#:- O: %*L*C+,O: FA$ <pad name> OF <menu name>
*). &C.1@&.2 M2N4:- Display and acti%ate the menu.
Syta#:- AC+,HA+* 9*:U <menu name>
&hat i! 'e'o field( )o" it "ork!(
Memo field used to store the long tetual information. Suppose $e considered that you need to create a
dbf ha%ing information as bookDname, authourDname, L bookDsummary. 7ere $e store
bookDname,authourDname in character field, but $e canWt use the character field for summary, because character
field canWt be $ider than ),+ character. So you use the 9*9O
field for storing the summary.
:hen a memo field used $ith in database file ,the actual information in memo field stored in auiliary
database file. Fopro automatically create the auiliary file -.fpt. $hen you create the memo field in dbf.
For eample if you create a database file like data/dbf ha%ing memo field fopro create t$o files data.dbf
L data.fpt $hich is auiliary file.
&D@&N.&G2 o! M2MO F12(D:-
! memo field occupies only &= bytes of space in database record. Pou
can store any amount of tet for each record.
!s actual data for the memo field stored in auiliary file, the siAe of main dbf
2educed.
2teri" Data 1 Memo Field
To entered data in memo field, ensure that the cursor is positioned in the memo field L press X7ome or
X#gdn. If you ha%e a mouse you can double6click on JmemoK.
This opens the $indo$ for entering the tet for memo field for the record. !fter you entered the
information press X: to close the &indo&/ 4r select File Xclose from foxpro menu/
Fopro returns you to editCappendCbro&se $indo$, no$ you see that JmemoK $ill change to JMemoK .
9emo indicate that it contain the data $hereas memo indicate that it canWt contain the data.
In this $ay you can entered the data in memo field.
Li!ting *e'o Field
:hen you gi%e L,%+ command to display the content of field on screen, it canWt display the content from
9emo field/ To display it you must type the name of that field
e/)/ list b2name4a2name4summar.. By default $idth of memo field is ,= character. This default $idth can be
changed through the %*+ 9*9OW,$+0 command.
For e/)/ %*+ 9*9OW,$+0 +O 3A
L,%+ OFF <2:A9*4A2:A9*4%U99A-8
&hat +! Re,ort - Lael! +n Fox,ro.
Esing 3IST command you canWt gi%e the presentable output form also it donWt ha%e the facility to include
page title,page number,date,headings etc. you canWt also apply the format to the tet. But fopro gi%es the facility
as 2"#42T to create the presentable output form.
Feature! .f Fox,ro Re,ort!:
! page title can be gi%en to the report.
!ny field epression can be placed any$here in detail line.
Descripti%e tet can also include in the page.
2eport title can be print on e%ery page.
The report can ha%e the page footer that print6 tet,field,%ariable,function to display the information.
The data in the report can be grouped.
#rint style-bold,italic,underline,color. can be gi%en to tet.
(alculation such as sum,a%erage,maimum,minimum can be performed on numeric field.
)o" /o Create /he Re,ort
To create the report C-*A+* -*FO-+ command is used.
Tip56 before creating report open the data base file for $hich you $ant to create the report.
Synta56 (2"!T" 2"#42T H>!M"I
When .ou )i(e the command (2"!T" 2"#42T command it open the &indo& &ith the )i(en name S
extension .fr. for e/)/ D!T!.F2Q
+he screen di(ided into three parts '
F)head' used to displa. the report titled4column headin) or description/
17
$etail' used to displa. the field information that &ill actuall. form the report/
F)foot' used to displa. the fooer information that &ill appear on each pa)e/
Creati" ?uic, Report
When .ou )i(e the (2"!T" 2"#42T command .ou &ill see the -*FO-+ menu is added to
the foxpro menu/ For Iuick report '
17 Click on -eport menu it displa. the menu options /
37 From this select Suick 2eport it displa. the report la.out6Column4Form la.out7 select an.
one S click on OK/
:o& .ou &ill see the format on .our &indo&/
PreFie'i" .he Report
Foxpro anable .ou to pre(ie& the report before printin)/
Click on 2"#42T menu then select #!?" #2"VI":.
SaFi" .he Report
+o sa(e the report press WW or select Sa%e form File menu/
Geerati" .he Report
:o& .ou can )enerate the report usin) -*FO-+ FO-9 command .ou can specif. the report
format file /
e.g. ES" STED
2"#42T F42M STED">T
8ou can also see the report in page6by6page (ie&/ +o use this mode add the clause F-*H,*W to
2"#42T F42M command/
For e.g. 2"#42T F42M STED">T #2"VI":
Priti" .he Report
8ou can also print the report on printer b. addin) the clause +O F-,:+*- to -*FO-+ FO-9
command/ ,t displa. report on screen as &ell as printer/
For e.g. 2"#42T F42M STED">T T4 #2I>T"2
:o& .our printer print the report/ ,f printer on then it print the report other&ise )i(e the error messa)e/
,f .ou donYt &ant to see the report on screen )i(e >4(4>S43" as
e.g. 2"#42T F42M STED">T T4 #2I>T"2 >4(4>S43"

Priti" Selected Report
8ou can also print the selected report usin) F42 clause/ As
2"#42T F42M STED">T F42 (ITP GK87!M?!4>K
Sa%ing The 2eport Into Tet File
+he report )enerated &ith the 2"#42T F42M command can be sa(e the record in other text
file/
For e.g. ES" STED
2"#42T F42M STED">T T4 FI3" STED.TQT
Creati" .he Custom Report
8ou can also create the custom report/ %teps to create the report'
1/ Open the DBF file S )i(e the command (2"!T" 2"#42T STED">T
3/ ,t displa. the &indo& in #g7ead )i(e the title of report as U9ark sheet of student#/
?/ +hen mo(e the cursor to next line S )i(e the column name as :A9*4 COU-%*
CF4CF4FOEF-O4%A$4O-ACAL +O+AL4F*-4-*%UL+4J-A$*/
@/ +hen mo(e the cursor to the D"T!I3 line S press WF to open the field expression box a)ain press
">T"2 button/ :o& it displa. the -eport *xpr/ box select the field name from field list at left side/
S select 48. A)ain select 48.
Tip56 you can press X: instead of selecting 48 button.
A/ ,n this &a. .ou can select the other fields &hich .ou &ant/
P/ +hen mo(e the cursor to #gFoot S t.pe D!T"56 to displa. current date press WF to displa. the field
expre/ box S a)ain press ">T"2 button/ From this select the Date-. from date function/ S press X:
t$o times.
D/ :o& to see the report press XI or select 2"#42T6#!?" #2"VI":.
Shortcut 3ey 1 Report
Ke. 9eanin)
1/ W, Fa)e Fre(ie&
3/ WF Open field expression box/
?/ WO -emo(e the line
@/ W: Add :e& Line
A/ W< Create <ox
P/ WJ <rin) to front
D/ WZ %end to back]
Groupi" O! Data 1 Report
8ou can )roup the data in report/ For exam/ suppose .ou &ant to )roup the emplo.ees from
same cit. to )et the )rouped the report 4.ou need to arran)e the record of database in same order/
ST"#S56
1/ first open the database S index it as
ES" "M#3
I>D"Q 4> (ITP T4 (ITP
3/ +hen )i(e the command (2"!T" 2"#42T "M#( it opens the &indo&/
?/ Ji(e the title (ITP:IS" *9FLO8** ,:FO-9A+,O: S )i(e the headin) of columns as .ou
&ant /6like :A9*4$O<4$OZ4<A%,C4:*+FA87/
@/ +hen mo(e the cursor to D"T!I3 B!>D S press WF to add field S a)ain press ">T"2 it displa.
the fields select one S press X: t$o times.
A/ ,n this &a. .ou can create the fields /:o& select 2"#42T menu L select D!T! ?24E#I>?. ,t
sho& the box select !DD push button it displa. another dialo) box press here ">T"2 L select the
field (ITP &hich .ou index/ Spress X: three times. :o& .ou &ill see on Line is displa.ed abo(e S
belo& the detail band like 1'Cit./ +.pe there C,+8' S press WF S press ">T"2. %elect (ITP L
press X: t$o times.
P/ :o& mo(e cursor to p)foot S )i(e footer information S see the report pre(ie& b. pressin) XI. 8ou
&ill see the )rouped data b. cit. &ise/
CR2&.1NG (&B2(:-
Foxpro pro(id another facilit. for desi)in) S printin) the mailin) label/ +he extension of .3BQ
+o create label format file (2"!T" 3!B"3 command is used/ When .ou create label .ou must
open the dbf file for &hich .ou create the label/
%teps'
1/ Open the database file as U%* *9FLO8**
3/ +hen )i(e the command C-*A+* LA<*L *9FL
?/ ,t displa. the &indo& here the default siNe is ? [# E 1AC1P# E 3 .ou can also chan)e it manuall./
@/ then mo(e the cursor to the :IDT7 S )i(e the &idth /
A/ mo(e cursor to >umber !cross6 it menas ho& man. labels placed in one ro& /
P/ mo(e cursor to Space Bet$een ^ it indicate that ho& man. space left bet&een the labels/
D/ mo(e cursor the 3ines Bet$een6 it indicate that the (ertical distance bet&een t&o label/
\/ .ou can set the hei)ht of label/
B/ to entered the field expression press WF it displa. the box select the field S press WW/
1>/ ,n this &a. .ou can add number of fields in label 4 if .ou add the self textCpromptin) then t.pe the
text in U # s.mbol/like ]:ame']/
11/ +hen to see the pre(ie& press W,/ +o sa(e the label press WW/
Geerati" .he (abel
:o& .ou can )enerate the label usin) 3!B"3 F42M command .ou can specif. the report
format file/
e.g. ES" STED
3!B"3 F42M STED">T
8ou can also see the report in page6by6page (ie&/ +o use this mode add the clause F-*H,*W to LA<*L
F42M command/
For e.g. 3!B"3 F42M STED">T #2"VI":
8ou can sa(e the label to another text file as
ES" STED
3!B"3 F42M STED">T T4 FI3" MPFI3".TQT
8ou can also print the label to printer as
ES" STED
3!B"3 F42M STED">T T4 #2I>T"2
19
8ou can print the selected records as
ES" STED
3!B"3 F42M STED">T F42 2"SE3T GK#!SSK
2#plai the di!!erece bet'ee 2X1. 7 (OOP commad i do 'hileBeddo
+he normal procedure to exit the $O W0,L* ^*:$$O statement is &hen the specified
condition becomes false/
0X+/
There is another $ay to terminate the loop using
"QIT command $ithin D4 :7I3" _">DD4
statement. :hen fopro encountered the "QIT
command ,no more commands from the loop is
eecuted. It eit the loop L eecuted the statement
net to the ">DD4 statement. The "QIT command
is normally used in IF _">DIF statement.
For e/)/
For e/)/
%tore > to x4sum4. store > to x4.4sum
$o &hile x<"A $o &hile x<"A
,nput U*nter :o/# to . ,nput U*nter +he :o/# to .
,f .<> ,f .<>
*xit LOOF
*lse else
%um"sum=. sum"sum=.
*ndif endif
E"x=1 x"x=1
5Ysum of no/ isY4sum 5Ysum of no/ isY4sum
Di!!erece bet'ee 11F56 7 1F statemet
IF is decision making statement. These are of t$o forms IF..">DIF L IF_"3S"..">DIF. The
first statement check the condition L if it is true eecute the command , other$ise Cump out off loop.
:here as second if condition is T2E" the true statement is eecuted other$ise F!3S" statement is
eecuted.
+he format is'
,f <condition>
^
<command>
^
endif
for e/)/ consider the follo&in) pro)ram
I>#ET J">T"2 P4E2 S!3!2PK T4 S!3!2P
IF S!3!2PI*===
TK P4E2 S!3!2P IS M42" T7!> *===K
">DIF
:hen you run this program fopro prompts you if you entered the salary greater than *===
other$ise it display no message.
IIF-. ^ The IIF-. function, that is also same as IF.."3S"..">DIF. This function return one
epression if the condition true, return the T2E" statement other$ise F!3S" statement. Both these
epression specified $ithin IIF-..
%.ntax' IIF-(4>DITI4>,T2E" ST!T"M">T,F!3S" ST!T"M">T.
For e/)/
5,,F6salar.>?>>>4#salar. more than ?>>>#4#salar. less than ?>>>#7
if the condition is true then 4#salar. more than ?>>># is executed other&ise
Usalar.less than ?>>># executed/
Di!!erece bet'ee FOR B2NDFOR 7 SC&N B2NDSC&N
F42...">DF42 eecutes a set of statements $ithin a loop a specified number of times. !
memory %ariable or array is used as counter to specifiy ho$ many times the statement eecuted
inside the loop. (onsider the follo$ing prog.
ST42" = T4 >EM
L..P
LOOP is another statement used
in DO WHILE ..ENDDO
statement. LOOP is specifed
ithin I! "ENDI!. When #o$pro
encountered the LOOP
command%the contro& pass to the
DO WHILE statement%the
remainin' commands( upto
ENDDO ) can*t e$ecuted. It a'ain
chec+ the condition , e$ecute
F42 >EM6 & T4 &=
TSS2T->EM.
">DF42
By default F42...">DF42 increments the %ariale by &.ho$e%er if you $ant to increase<decrease the
%ariable 9<6 sign is used after ST"# option like ST"# ^* or ST"# *.
S(!> _">DS(!>56Mo%es the record pointerthrough the current DBF file L eecute the
block of commands for each record that meets the specified condition/
%.ntax'
S(!> FS(4#"'
FF42 Hep3I'
F344#'
F"QIT'
">DS(!>
For e/)/
ES" address
!(("#T J">T"2 (ITP56J T4 M(ITP
S(!> F42 (ITPGM(ITP
T>!M"
T(ITP
TDIST
T
">DS(!>
Di!!erece bet'ee 1ND2X 7 SOR.
1ND2X SOR.
&. It arrange the record in inde file. &. It sort the records in ne$ DBF file.
). It reMuired less memory as it arrange ). It reMuired same memory as the
<store only the record number. 4riginal database.
*. The etension of inde file is .IDQ *. The etension is .DBF
-Simple inde. L .(DQ-(ompound
inde. file.
+. The ne$ data automatically update +. >e$ data $ill not be update.
$hen added.
%.ntax' %.ntax'
I>D"Q 4> Ffield,field,_' to Fid file' S42T T4 Ffilename' 4> Ffield,_'
T!? Fcd file'Fascending<descending' FF42 Hep3I'
For e.g For e.g.
Ese stud use stud
Inde on rollno tag roll sort to stu on rollno
0x,lain ho" to generate !creen.
Pou can also creat the screen using C-*A+* %C-**: command. Screen builder is most useful facility in
fopro. In this you Cust place the tet,fields L %ariables on the screen at desired position. Pou can easily mo%e the
obCect on the screen. Pou can also format the screen. 4nce you satisfied the apperence you may generate the
screen.
ST"#S56
4pen the data base for $hich you $ant to creat screen.
?i%e the command C-*A+* %C-** %+U$/
It open the $indo$,for Muick screen you select S(2"">`SEI(8 S(2"">
or you can press XF to add field. It display the field epr. bo , to input the tet select H?et..I or to display
list select HSay..I then select the field L press X: t$o times.
In this $ay you can select the fields you $ant .
To generate the code select #24?2!M`?">"2!T" option from it display the screen generate bo select
the appropriate option L select ?">"2!T".
!fter this press X: L to eecute the screen gi%e the command
$O %+U$/%F-
It display the screen .
&hat i! R1B0( 0x,lain it "ith exa',le(
2SB" means 2elational Suery By "ample. Suery means the process of etracting specified
information from file<table. Pou can relate t$o different tables<files to create ne$ file.
To create Muery file C-*A+* GU*-8 <:A9*> is used. The etension of Muery file is /G-8/
Pou can order the data by using O-$*- <8 option. By using J-OUF <8 option you can create group
-1
of data. Pou can also create the specified condition using 0AH,:J option. To run<eecute the Muery D4
Hname.etI command is used. For e.g.
$o %tud/Gr./
%+*F%'
1/ 4pen the data base to $hich you $ant to create the Muery. U%* %+U$
3/ ?i%e the command (2"!T" SE"2P STED it opens the $indo$.
?/ Then select O-$*- <8 to order<inde the record. It display the $indo$ select the fields $hich
you $ant L select ascending<descending option L select ok.
@/ Then select 0AH,:J <8 it display the $indo$, under field name select the field 6for e/) C,+87 L
mo%e the cursor to net tab select here the option from drop do$n list-for e.g. L,K*.,then mo%e the
cursor to net tab type here the condition6for e/)/ U%0*JAO:#7.- If you $ant to etract the record
for cit. Ushe)aon# or salar. )reater than ?>>>/ then you use 42 option L then mo%e tab to field
name select salary field then mo%e cursor to net tab select here more than option ,then mo%e the
cursor to net L type *===. . select 48.
A/ To see the Muery select $O GU*-8 option from $indo$. It display the list in bro$se form.
+ip' instead of 42 you can use !>D operator. Pou donWt specify the operator you Cust select the net
field.
To sa%e the Muery press X:. To eecute the Muery gi%e command
$O %+U$/G-8 in command $indo$.
<hat is .2X.-2ND.2X.G
:hen you need to display the tet use T<TT instead of this you can use T"QT6">DT"QT to
display long message. Pou donWt reMuire to use Muotations ,you can type se%eral lines. Pou can also print
the tet on #2I>T"2.
For e.g.
\),& say JDisplay The menuK
T"QT
& !dd 2ecord
) Modify 2ecord
* Delete 2ecord
+ "it
">DT"QT
The abo%e command display the matter on screen from tet..endtet.
2#plai the C&(C4(&.2 commadG
(alculate is multipurpose command that you use to perform %arious mathematical function. The
function include sum,a%erage,min,ma etc.
%.ntax'
CALCULA+*<exprlist>
[<scope>] [FO- <expL>] [+O <mem(ar list>]
e.g. ES" S!3"S
(!3(E3!T" SEM-#24FIT. T4 T#24FIT
TT#24FIT
(alculate the total of profit field L stor it into T#24FIT field.
&hat i! !tructural co',ound index file(
! compound inde file can hold more than one inde file in a single file. "ach inde file $ithin a
compound inde file is called inde tag. The compound inde file gi%en a etension .(DQ It is also
called %tructural Compound inde file. It has same name as the opened .DBF file $ith etension .(DQ .
Pou can also create separate compound inde file $hich is called ,ndependent Compound inde file
-$ith etension .(DQ. but this file $ill not open automatically $hen DBF file open. The records can not
reinde $hene%er you $ill not open the independent compound inde file.
For e.g.
ES" STED
I>D"Q 4> >!M" T!? >!M"
It create structural compound inde file $ith name STED.(DQ.

Você também pode gostar