SlideShare a Scribd company logo
1 of 65
S. MADHU MOHAN FOXPRO
FOXPRO
The old version FoxPro is “FoxPro2.0” (Dos based). Latest version of FoxPro is
“FoxPro 2.6” and “Visual FoxPro” .
FoxPro 2.6 is a Dos based FoxPro. This is a CUI (Character User Interface) user.
Visual FoxPro is a Window based FoxPro. This is a GUI (Graphical User Interface)
user.
FoxPro is a DBMS package.
DBMS : Data Base Management System.
Example : FoxPro, dbase, Clipper etc.
RDBMS : Relational Data Base Management System.
Example : Oracle, Sybase etc.
ORDBMS : Object Relational Data Base Management System.
Example : C++ ,VC++ etc.
Data means : Some information (or) An unprocessed information Regarding any
object.
Means : Fields – Columns
Records – Rows
Tables – File
DBF – Data Base file.
Note :
All FoxPro commands are used full (or) 4 characters.
COMMANDS :
CREATE :
To create a database file.
Syntax : create <file name>
Example : create madhu
LIST :
Display the contents of dbf files. (or) Display all records, (or) Lists all the
records of the currently active dbf along with record no’s.
Syntax : list (or ) F3
1. list name, no
Example : list name, no
2
S. MADHU MOHAN FOXPRO
2. To display name,no,total, fileds where no=2
Example : list name,no,total for no=2
3. display records whose no>2
Example : list for no>2
4. display records whose no<2
Example : list for no<2
5. displaying records no>2
Example : list for recno()>2
6. List off :
Suppress(hides) records no column.
List for name= “mohan”
List while course
List while course= “PGDSE”
List name,no for course= “PGDSE” to print
List for deleted()
APPEND :
To add the records to the existing DBF.
Syntax : Append
USE :
To open particular data base file.
Syntax : Use <file name>
Use mohan
QUIT :
Exit from the FoxPro.
Syntax : Quit
BROWSE : (Ctrl +N )
Browse opens various options it allows editing several records in the full screen
window. To insert a new record to the bdf in browse option.
Syntax : browse
DELETE :
Deletes particular record or range of record.
1. To delete 5th
record.
Goto 5
Delete
3
S. MADHU MOHAN FOXPRO
2. To delete records>10
Goto 10
Delete rest
Delete for recno()>10
3. To delete records>10 and <=15 (11,12,13,14,15)
Delete for recno()>10 and recno<=15
4. To delete records permanently from the dbf.
Delete recno()=5 and recno<=10
Pack
5. Delete for upper (name)= upper (smm)
Delete for no>10
RECALL :
To recall the deleted records. Which are delete d by delete command.
To recall 3rd
record
Goto 3 recall all
Recall recall next 5
MODI STRUCTURE :
We can make modifications in the existing dbf structure., like modifying
width of column, modifying name of the column, adding new column (ctrl + I ) and
deleting column.
Syntax : modi stru
EDIT :
Edit used for making modifications in a particular record modifications in
100 records.
Example : Goto 100 Goto top(1 record) Goto bottom (100 record)
Edit Edit Edit
REPLACE :
This command replaces the existing column or field with a new value or
text.
Syntax : replace <condition>
Example :
1. Finding total.
Replace all total with m1+m2
2. Finding average.
Replace all average with total/2
Replace all average with m1+m2/2
4
S. MADHU MOHAN FOXPRO
3. Assign 1000 Rs. Bonus for all employees.
Replace all Bonus with 1000
Replace all Bonus with Basic*10/100
4. Assign depart name for department colum.
Replace all Dept with “Finance”
5. To convert name into upper case.
Replace all name with Upper(name)
6. To convert name into lower case.
Replace all name with lower(name)
7. To convert name into proper case.
Replace all name with proper(name)
8. Replace name Hari Shankar where roll no=4.
Replace name with “Hari Shankar” for no=4
9. Replace name with lower (name) for function>=number
Upper another
DISPLAY :
Displays the current record of the active data base file.
Syntax : Display
1. Display Files : Lists files on the current directory.
2. Display History : Lists the command in the History mode in the order of entry.
3. Display Memory : Displays the Name, type and size of the active memory
variables.
4. Display Status : Displays information about open files and system parameters.
5. Display Structure : Displays the structure of the file in use.
(or) Displays the structure of existing data base file.
APPEND :
This command allow user to expend the data file by giving new records.
Syntax : Append
Examples : 1. Append : adds records at the end of file.
2. Append Blank : Adds one blank record at the end of a file.
3. Append From file name : Adds records of new file name. dbf.
ERASE :
Removes a file from the directory permanently.
Syntax : Erase <file name.
Example : Erase madhu.dbf
Erase mohan.prg
5
S. MADHU MOHAN FOXPRO
Note : This command is not applicable for the files which are currently active in the
memory.
PACK : Removes records permanently from the dbf file.
CLOSE :
Close, closes the type of the specified and makes the buffers empty and ensures
that the closed files are upto date.
Syntax : Close
CLOSE ALL :
Specifies all the active files which are opened to be closed. (or) close all data
base file.
Syntax : Close all
ZAP :
Removes all the records irrespective of having been marked or not marked for
deletion.
Syntax : Zap
FUNCTION KEYS :
KEY WORKING COMMAND
F1 Help
F2 Assist
F3 List
F4 Dir
F5 Display Structure
F6 Display Status
F7 Display Memory
F8 Display
F9 Append
F10 Edit
DELETED( ) :
Returns .T. if the current record is marked for deletion, otherwise .F.
Example : 1. Use madhu.dbf .T. = True
Goto 2 .F. = False
?Deleted( ) ? = Print symbol.
Delete
?Deleted( )
6
S. MADHU MOHAN FOXPRO
2. Delete for no>2
List for Deleted( )
List for records which are marked for deletion.
LOCATE :
Locate finds the first record in a dbf that matches a search criterion (condition)
specified in the for or while portion of the command. If locate fails to find a matching
record, the EOF( ) function is set to .T. and the Found( ) function set to .F.
Syntax : Locate Scope [for <condition>] [while<condition>]
Example : Locate for name= “madhu”
Delete
Locate for no5= “S”
Delete
GOTO :
Positions the record pointer at the specified record position.
Syntax : Goto Recno [top][bottom]
Example : Goto 10 Goto Top Goto Bottom
Display Display Display
SKIP :
Skip to the next record in a database. Can also skip more or less than one record
when the following command is used.
Syntax : skip[n] [n=number]
Moves the record pointer to a specified no of records from the current record
position.
“N” is a number which can be either positive or negative. If “N” is a positive
number, then the record pointer moves in the forward direction. Otherwise moves in the
backward direction. If no value is given +1 is default.
Example : 1. Skip - Skips to next record.
2. Skip 4 - Moves to 4th
record forwards.
3. Skip -3 - Moves to 3rd
record backwards.
COPY :
1. Makes a copy of an existing file in disk.
Example : copy to new file.
2. copy structure : copy structure to new file. Copies only structure of current dbf
into a new file.
7
S. MADHU MOHAN FOXPRO
3. copy to new file for name= “mohan”
Syntax : copy to new file for name= “name”
Copies all the records having the name “mohan” into new file.
4. copy file madhu.prg to mohan.prg
Copies madhu.prg into mohan.prg on the same list.
OPERATORS
An operator is a symbol (or) a set of characters which perform a pre-defiend
operation.
1. ARITHMETIC OPERATORS :
These operators which perform an arithmetic operation. Usage of these
operators is limited to numeric data type. But the operators plus(+), minus(-) can be
used on date data type also. The various arithmetic operators are.,
Symbol Uses
+ (plus) Addition 10+20=30
Any Date +1 Display Next day
31-05-2007 +1 01-06-2007
– (minus) Subtraction 20-10=10
Any Date -1 Display Yester day
02-06-2007 -1 01-06-2007
* (asterisk) Multiplication 10*5=50
/ (slash) Division 10/5=2
^ or ** (copy symbol) Exponentiation 2**3=8 (2*2*2)
2^3=8 (2*2*2)
( ) (brackets) Grouping [(15*10)+(20*5)
50+100=150]
2. RELATIONAL OPERATORS :
These operators are used to compare two same type of values. The result
of search a comparison will be either of the two : .T. or .F. These operators can be
used on numeric, character and date data type.
Symbol Uses
= (equal) Equality (300=300) = .T.
RAMA= rama = .F.
> (greater than) Greater than (500>600) = .T.
(500>300) = .F.
Bruce=amar=.F.
< (less than) Less than (200<100) = .T.
(100<200) = .F.
8
S. MADHU MOHAN FOXPRO
Symbol Uses
>= Greater than equal to
<= Less than equal to
<> or # (not equal) 5<>5 = .F. 5#5 = .F.
5<>6 = .T. 5#6 = .T.
$ (dollar sign) (Useful for character type.
Character 1 $ character 2 returns .T.
If character1 in character 2)
Vijaya $ Vijayawada = .T.
Vijayawada $ Vijaya = .F.
3. LOGICAL OPEATORS :
These operators compare two or more expressions of numeric, character
and date data type and either .T. (or) .F. result.
Symbol Uses
.AND. states that both expressions compared are true (.T.)
.OR. states that either of the two expressions is .T.
.NOT. states that the expression is not true .T.
FILES IN FOXPRO AND THEIR EXTENSIONS :
Extension File Description
.DBF Data base file.
.DBT Data base text file.
.FMT Format file.
.FRM Formatted report file.
.LBL Label file.
.MEM Memory file.
.NDX Data base Index file.
.PRG program file.
.QRY Query file.
.SCR Screen setting file.
.VUE View file.
.CAT Catalo file.
9
S. MADHU MOHAN FOXPRO
RETURN DOS :
QUIT :
Closes the open file, active updated data base file and quits FoxPro and returns to
the Dos prompt permanently. If you need FoxPro once again you have to load again by
entering the command FoxPro.
! (or) RUN :
Invokes the operating system temporarily and executes a valid internal or
external dos commands and returns to FoxPro immediately. The current disk must
contain the file command.
Syntax : ! <dos command> or run <dos command>
Example : ! dir run dir
SORT :
Re-arranges records on a data base file into sorted order. It require that records
be sorted to another data base file.
Syntax : Sort <scope> to <filename>on <field>[/a][/d][/c] scope
[,<additional fields>[(/a)(/d)(/c)] {next, rest,
[while <condition>][for<condition>] all}
Note :
<scope> scope is FoxPro scope option.
<file name> File name is the name of FoxPro.
<field> Field is the name of the feel on which the data base records or to be
sorted.
/a indicates ascending order.
/d indicates descending order.
/c indicates that upper case & lower case difference are to be ignored.
While sorting on a character field. If this is ignored, the sort takes place in
the order of ASCII values.
ADDITIONAL FIELDS :
They are the field names to be taken as secondary fields when the primary field
value is repeated in the data base.
For and while specifies the condition, so that only the records matching the given
condition will be copied on to the new file.
Up to 10 fields can be included in the sort. Fields should be listed from left to
right in order of importance.
Example : Sort on sname, maths, science to sroted file.
Sort on name/ac to new file. “/a” {ascending, upper/lower cases)
10
S. MADHU MOHAN FOXPRO
INDEX :
Index command includes up to seven index files, that have been created
previously with the “index on” command. {dir *.idx – to see index files)
Syntax : Index on field to <file name>
Example : Index on sno to no
FIND :
Find quickly finds a value in an index file and sets the record pointer into that
record.
Syntax : Find <constant>
If find is successful, then “found ( )” function returns .T. , otherwise “found ( )”
function returns .F..
Example : Find 100
Find mohan
SEEK ( ) :
Seek looks up the contents of a memory variable in an index file. Its supports
both memory variables and expressions.
If seek is successful, the “found ( )” function is set to true.
Syntax : Seek <expression>
Example : Seek 100 Seek 100
Seek mohan Seek N, Name= “mohan”
Seek upper(name)
TYPE :
Displays the contents of a disk file and also prints the contents of a file.
Syntax : Type <file name> [print]
Example : Type mohan, type mohan.prg to print
RENAME :
Changes the name of a given old file with a new file. It does not effect the
contents of the file.
Syntax : Rename <old file name> to <new file name>
Example : Rename madhu.prg to mohan.prg
DATA TYPES:
Data Type Maximum Width Default
Character 254 10
Numeric 20 8
11
S. MADHU MOHAN FOXPRO
Date 8 8
Logical (T/F) (Y/N) 1 1
Memo Ctrl+PgDown(whole window) 10
Float 8
Picture
General
SET COMMANDS :
The “Set” commands when used alone, display all current parameter setting and
allow them to be changed through a menu.
“Set” displays a full screen menu – driven technique for viewing and changing
current parameter settings.
1. SET ALTERNATE [ON][OFF] :
Determines where ensuring screen text is sorted on the currently active
alternate file.
2. SET ALTERNATE TO [FILE NAME] :
Creates an ASCII text file to which FoxPro can direct output. The
command without any file name closes the currently active alternate file.
3. SET BELL [ON][OFF] :
Determines whether the warning bell sounds when you type beyond the
width of a field or enter invalid data type.
4. SET CENTURY [ON][OFF] :
Allows the input and display of century prefixes on the year portion of
dates.
5. SET DECIMAL TO [WIDTH] :
Determines the minimum number of decimal places displayed in the
results of numeric expressions.
6. SET DATE <DATE FORMAT> :
“<Format>” is any valid FoxPro date format, which can be any of the
following.
American MM/DD/YY
German DD.MM.YY
British DD/MM/YY
French DD.MM.YY
12
S. MADHU MOHAN FOXPRO
7. SET ECHO [ON][OFF] :
Displays command lines from FoxPro program on the screen or the
printer while running the programmes.
8. SET FUNCTION <KEY> TO <STRING> [;] :
Allows each function key to be reprogrammed to represent character
expression up to 30 characters long “<key>” is the number of the function key to be
program “<string>” is the character expression which you would like to generate by
pressing that function key.
“[i]” includes an auto carriage return to that string.
Example : Set Function F11 to “clear”
Set Function F12 to “create”.
Assigns the command clear to F3 and also includes a return.
9. SET HISTORY [ON][OFF] :
Determines whether commands are stored in the History file or not.
10.SET MARGIN TO <NUMBER> :
Specifies the left margin for the printer outputs.
11.SET PRINT [ON][OFF] :
Directs all output that is not formatted with the at [@] …. Say commands
to the printer and the screen.
12.SET TALK [ON][OFF] :
Determines whether certain commands display informative message.
13.SET STATUS [ON][OFF] :
Determines whether the status bar is displayed at the bottom of the screen.
14.SET COLO [ON][OFF] :
Displays the colors from FoxPro program on the screen or the printer
while running the programs.
15.SET CLOCK [ON][OFF] :
Displays or sets the clock from FoxPro program on the screen.
16.SET SAFE [ON][OFF] :
Determines whether the FoxPro program running the computer the
computer should be safe.
13
S. MADHU MOHAN FOXPRO
Ctrl + F7 :
This command is used for moving command window one location (place)
to another location by using arrow keys.
Ctrl + F8 :
This command is used for we can increase or decrease the command
window by using arrow keys.
Ctrl + F7 :
This command is used for to hide or unhide showing the command
window.
Ctrl + W :
This command is used for to save the FoxPro program.
PROGRAMS
1. Write a program to display name, no, course.
Solution : MODI COMM MADHU.PRG
Set talk off
Clear
Accept “Enter Your Name :” to name
Input “Enter Your Number :” to no
Accept “Enter Course Name :” to course
Clear
? “Name :”, name
? “Number :”, no
? “Course :”, course
^w
Output
Do Madhu
2. Write a program to calculate the addition.
Solution : MODI COMM ADDITION.PRG
Set talk off
Clear
A=100
B=200
C=A+B
? “Sum :”,C
^w
Output
Do Addition
Sum = 400
14
S. MADHU MOHAN FOXPRO
3. Write a program to accept student name, no, marks in 3 subjects. Find total and
average marks and display them.
Solution : MODI COMM STUDENT.PRG
Set talk off
Clear
Accept “Enter Student Name :” to sname
Input “Enter Student Number :” to sno
Input “Enter Marks in Oracle :” to m1
Input “Enter Marks in HTML :” tp m2
Input “Enter Marks in SAP :” to m3
Total=m1+m2+m3
Average=total/3
Clear
? “Student Name :”, sname Output
? “Student Number :”, sno Do Student
? “Oracle Marks :”, m1
? “HTML Marks :”, m2
? “SAP Marks :”, m3
? “Total Marks :”, total
? “Average Marks :”, average
^w
4. Write a program to accept employee name, no, basic, hra, da, ta, pf. Find gross
salary and net salary.
Solution : MODI COMM EMPLOYEE.PRG
Set talk off
Clear
Accept “Enter Employee Name :” to name
Accept “Enter Employee Number :” to no
Input “Enter Basic Salary :” to basic
Input “Enter HRA :” to hra
Input “Enter DA :” to da
Input “Enter TA :” to ta
Input “Enter PF :” to pf
Gross salary = basic+hra+da+ta
Net salary = gross salary – pf
Clear
? “Employee Name :”, name
? “Employee Number :”, no
? “Basic Salary :”, basic
? “HRA :”, hra
? “DA :”, da
? “TA :”, ta
? “PF :”, pf
? “Gross salary :”, gross salary
? “Net salary :”, net salary
^w
15
S. MADHU MOHAN FOXPRO
CONTROL STATEMENTS :
1. If ……. Endif
2. If ……. Else ………. Endif
3. Docase …….. Endcase
If …. End if :
If statement checks the given condition. If the condition is satisfied, then
executes the statements which are mentioned between “if” and “endif” .
Syntax : If <condition>
Statement
Endif
5. Write a program for demonstrating “if” condition.
Solution : MODI COMM IF.PRG
Set talk off
Clear
Input “Enter Any Number :” to no
If (n>0)
? “This is a Positive Number :”, no
Endif
^w
If …. Else …. Endif :
If statement executes the statements when the condition is satisfied, else
executes the other statement which are presents after the else statement.
Syntax : If <condition>
Statements
Else
Statements
Endif
MOD ( ) :
This function is used to find the remainder from given expression.
Syntax : MOD (dividend, division)
Example : ?MOD (100,2) ? MOD (9,2)
Output : “0” “1”
6. Write a program to accept a number. Find whether the given number is even or
odd number.
Solution : MODI COMM EVEN.PRG
Set talk off
Clear
16
S. MADHU MOHAN FOXPRO
Input “Enter Any Number :” to no
R=MOD(no,2) Output
If (R=0) Any Number : 20
? “Even Number” Even Number
Else
? “Odd Number” Any Number : 25
Endif Odd Number
^w
7. Write a program to accept a year. Find leap year or not.
Solution : MODI COMM YEAR.PRG
Set talk off
Clear
Input “Enter Any Year :” to year Output
R=Mod(year,4) Any Year : 2004
If(R=0) Leap Year
? “Leap Year”
Else Any Year : 2007
? “Not Leap Year” Not Leap Year
Endif
^w
Docase ….. Endcase :
Docase statements executes one statement or case among number of cases,,
which case is satisfied they are given criteria.
End case is the terminator of docase.
@ say (row, column) :
This statement prints the message at the required place or location on the monitor
Get :
This command accepts some value or text into the variables. This get statement
must followed along with “@Say” command.
The screen divides 80 columns, 24 rows in FoxPro, or inserting the monitor.
Syntax : @row, column say “message” get <variable name>
STORE :
Store command used for declaring variables and storing some value into the
variables.
Store 0 to no, numeric values or variables.
Store 0 to no, basic, hra, da, ta, pf
To declare numeric variables and storing “0” in the above variables.
To declare character variables and allocating 20 spaces for the name variable.
17
S. MADHU MOHAN FOXPRO
READ :
So “Read” command stops the cursor after printing the message using “@say
command” also stores information into the variables.
8. Write a program to accept SMM Computers. Find even number, leap year,
negative number.
Solution : MODI COMM MADHU.PRG
Set talk off
Clear
Store 0 to no, R, year, G
@2,25 say “SMM COMPUTERS”
@4,15 say “1. Even or Odd”
@5,15 say “2. Leap year or Not”
@6,15 say “3. Positive or Negative”
@7,15 say “4. Exit”
@8,15 say “------------------------------“
@10,20 say “Enter Your Choice :” get no
Read
Docase
Case no =1
Input “Enter Any Numebr :” to R
R=Mod(no,2)
If (R=0)
? “Even Number”
Else
? “Odd Number”
Endif
Case no =2
Input “Enter Year :” to year
R=Mod(year,4)
If (R=0)
? “Leap Year”
Else
? “Not Leap Year”
Endif
Case no =3
Input “Enter any Number :” to G
If(g>0)
? “Positive Number”
Else
? “Negative Number”
Endif
Case no =4
? “Thank You very much”
? “S. MADHU MOHAN”
Endcase
^w Output : Do madhu
18
S. MADHU MOHAN FOXPRO
9. Write a program to accept customer name, product no, product name, quantity,
rate. Find the bill amount. If the amount is greater than 500 (>500)then discount is
10% (=10%) of the bill amount, if bill amount less than 500 (<500), display
message “Sorry! No Discount”.
Solution : MODI COMM CUSTOMER.PRG
Set talk off
Clear
Store space(20) to cname, pname
Store 0 to pno, prate, quantity, bill, discount, net bill
@6,15 say “Enter Customer Name :” get cname
@7,15 say “Enter Product Name :” get pname
@8,15 say “Enter Product Number :” get pno
@9,15 say “Enter Product Quantity :” get quantity
@10,15 ssay “Enter Product Rate :” get prate
Read
Bill=quantity*prate
@12,15 say “Total Bill Amount :” get Bill
If (bill>500)
Discount=bill*10/100 or Discount=bill*0.1
Else
Wait Window “Sorry! No Discoun”
Endif
Net bill=bill-discount
@13,15 say “Net Bill Amount :” get net bill
Wait Window “Thank You” time out 1
^w
WAIT WINDOW :
This command prints the message which is specified between the quotations
after this wait window until user press “Esc key” or Else we can specify time along with
this window.
Syntax : Wait window “some message” time out <minutes>
Example : Wiat window “S. MADHU MOHAN” Time out 1
COLORS :
Black – N Green – G Inverse – I Red – R
Blank – X Brown – Gr Magnenta – Rb White – W
Blue – B Cyan – Bg/Gb Yellow – Gr+ Underlined – U
Colors Background settings :
W+/B W+/BG GR+/B R+/B
W+/GR W+/N W/N U+/N
GR+/RB N+/N GR+/B ++G/B
19
S. MADHU MOHAN FOXPRO
10. Write a program to set the color for name madhu mohan.
Solution : MODI COMM COLOR.PRG
Set talk off
Clear
Set colo to R++ or R*
? “S. MADHU MOHAN”
Set colo to
^w
11. Write a program to accept student name, no, marks in 2 subjects. Find total,
average. If avg>=35 and <50 result =third class, avg>=50 and <60 result=second,
avg>=60 and <75 result= first, avg>=75 result= distinction.
Solution : MODI COMM STUDENT.PRG
Set talk off
Clear
Store space(20) sname, result
Store 0 to sno,m1,m2, tot, avg
@6,15 say “Enter Student Name :” get sname
@7,15 say “Enter Student Number :” get sno
@8,15 say “Enter Marks in FoxPro :” get m1
@9,15 say “Enter Marks in Internet :” get m2
Read
Tot=m1=m2
Avg=tot/2
@11,15 say “Total Marks :” get tot
@12,15 say “Average Marks :” get avg
If (avg>=35 .and. avg<50)
Result= “Third Class”
Else
If(avg>=50 .and. avg<60)
Result= “Second Class”
Else
If(avg>=60 .and. avg<75)
Result= “First Class”
Else
If (avg>=75)
Result= “Distinction”
Else
Result= “Fail”
Endif
Endif
Endif
Endif
@15,15 say “Result is :” get result
^w
20
S. MADHU MOHAN FOXPRO
CASE STRUCTURE or LOOPING STRUCTURE :
1. Do while …… Enddo
2. For ……. Endfor
Do While …... Enddo :
“Do while” loop executes the statements until the given condition is satisfied. If
the condition becomes falls it comes out from the loop that is do while loop.
“Enddo” is the terminator of the “Do while” loop.
Syntax : Do while <condition>
Statements
Enddo
12. Write a program to print 20 numbers.
Solution : MODI COMM NUMBERS.PRG
Set talk off
Clear
A=1
Do while(a<=20)
?A
A=A+1
Enddo
^w
13. Write a program to Hello! Mohan message 10 times.
Solution : MODI COMM HELLO.PRG
Set talk off
Clear
A=1
Do while(A<=10)
? “Hello! Mohan”, A
A=A+1
Enddo
^w
14. Write a program to print 20 numbers with reverse order (20 to 1).
Solution : MODI COMM REVERSE.PRG
Set talk off
Clear
A=20
Do while(A>=1)
?A
A=A-1
Enddo
^w
21
S. MADHU MOHAN FOXPRO
15. Write a program to print multiplication table for a given number.
Solution : MODI COMM MULTIPLICATION.PRG
Set talk off
Clear
Store 0 to A,B,C
Input “Enter any number :” to A
Do while(B<=10)
C=A*B
? A, “X”, B, “=”,C
B=B+1
Enddo
^w
16. Write a program to print 20 multiplication tables.
Solution : MODI COMM MULTIPLICATION.PRG
Set talk off
Clear
A=1
Do while (A<=20)
B=1
Do while (B<=10)
? R, “X”, A, “=”, B*A
A=A+1
Enddo
R=R+1
Wait “Continue”
Clear
Enddo
^w
For ….. Endfor :
“For” loop executes the commands until the condition becomes true. If the
condition becomes false it comes out from the “for loop”.
“End for” is the terminator of the “For” loop.
Syntax : For variable name= Initial value to Last value (step value)
Statements
Next of skip value
Endfor
17. Write a program to 20 numbers.
Solution : MODI COMM NUMBER.PRG
Set talk off
Clear
A=1
For A=1 to 20 Endfor
?A ^w
22
S. MADHU MOHAN FOXPRO
18. Write a program to print 20 numbers with reverse order (20 to 1).
Solution : MODI COMM REVERSE.PRG
Set talk off
Clear
A=20
For A=20 to 1 step -1
?A
Endfor
^w
19. Write a program to print multiplication table for a given number.
Solution : MODI COMM MULTIPLICATION.PRG
Set talk off
Clear
Store 0 to sno, A
Input “Enter any number :” to sno
For A=1 to 10
? sno, “X”, A, “=”, sno*A
Endfor
^w
20. Write a program to print 20 multiplication tables.
Solution : MODI COMM MULTIPLICATION.PRG
Set talk off
Clear
For A=1 to 20
For B=1 to 10
? A, “X”, B, “=”, A*B
Endfor
Wait
Endfor
^w
21. Write a program to accept student name, no, marks in 2 subjects. Find total,
average. If avg>=35 and <50 result =third class, avg>=50 and <60 result=second,
avg>=60 and <75 result= first, avg>=75 result= distinction. If marks <35
result=fail.
Solution : MODI COMM RESULT.PRG
Set talk off
Clear
Store space (20) to sname, result
Store 0 to sno, m1, m2, m3, tot, avg
@6,15 say “Enter Student Name :” get sname
@8,15 say “Enter Student Number :” get sno
@10,15 say “Enter Marks in C :” get m1
@12,15 say “Enter Marks in C++ :” get m2
23
S. MADHU MOHAN FOXPRO
@14,15 say “Enter Marks in VC++ :” get m3
Read
Tot=m1+m2+m3
Avg=tot/3
@16,15 say “Total Makrs :” get tot
@18,15 say “Average Marks :” get avg
If (m1>75 .and. m2>75 .and. m3>75)
? “Pass, Distinction” or Result= “Distinction”
Else
If (m1>605 .and. m2>60 .and. m3>60)
? “Pass, Fist Class” or Result= “First Class”
Else
If (m1>50 .and. m2>50 .and. m3>50)
? “Pass, Second Class” or Result= “Second Class”
Else
If (m1>35 .and. m2>35 .and. m3>35)
? “Pass, Third Class” or Result= “Third Class”
Else
? “Fail” or Result= “Fail”
Endif
Endif
Endif
Endif
^w
Functions
A function is a predefined program. Which performs a particular task or work.
DATE Functions :
DATE ( ) : Returns the system date.
Syntax : Date ()
Example : ?Date()
DAY ( ) : Returns the numeric value of the day of the month from a date.
Syntax : Day(<date>)
Example : ?Day(Date())
MONTH ( ) : Returns the number of the month in the date expression.
Syntax : Month (<date>)
Example : ?Month(Date())
YEAR ( ) : Returns the numeric value of the year from a date expression.
Syntax : Year (<date>)
Example : ?Year(Date())
24
S. MADHU MOHAN FOXPRO
CToD ( ) : Converts a character variable in date format to the date data type.
Syntax : CToD(“date”) (CToD= Character to date)
Example : CToD(“06/01/2007”) output : 06/01/2007
DToC ( ) : Date to character, converts any date to a character string.
Syntax : DToC(<date>) (DToC= Date to Character)
Example : DToC(Date())
CMONTH ( ) :
Current month or character month. Returns character month name of a given
date.
Syntax : Cmonth(<date>)
Example : Cmonth(Date())
CDOW ( ) : Character day of week.
Syntax : CDOW(<date>)
Example : CDOW(Date()) output : Thursday
LUPDATE ( ) :
Returns the date, as the date data type of the last “update” of the currently
selected data base file.
Syntax : Lupdate()
Example : ?Lupdate()
TIME ( ) : Returns the system time as the character string.
Syntax : Time()
Example: ?Time() output : 9:40:00
NUMERIC Functions :
COUNT( ) :
Counts how many records in data base, meet a search condition. The command
count alone counts how many records are there in the data base file.
For and While specify the condition for which the FoxPro searches and counts
the number of records matching the given condition.
[To <Memory variable>] specify the name of the memory variable in which the
data has to be stored.
Syntax: Count [For<condition>][While<condition>][To memory variable]
Example: Count()
Count to N
Count for course= “PGDSE” to PGTOTAL
? PGTOTAL
25
S. MADHU MOHAN FOXPRO
SUM ( ) :
The command sum alone returns the sum of numeric fields.
Syntax : Sum[<expre>][scope][For<expre>][While<expre>][To <memory variable>]
<expression> expressions are numeric field names or expressions of numeric fields.
<scope> scope is the (FoxPro) data base scope option.
Example : Sum()
Sum total to tot, ?tot
Sum total, for total>=200 to ABC ?ABC
AVERAGE( ) :
This command calculates the average of numeric fields.
Syntax :
Average[<expre>][scope][For<expre>][While<expre>][To <memory variable>]
Examples : Average ()
Average total to tot ?tot
Average total for total>=200 to XYZ ?XYZ
INT ( ) : (Integer – decimal)
Integer function, converts any numeric expression into integer by truncating (cut)
the decimal places.
Syntax : Int (<number>)
Example : Int (56.3482) output : 56
MOD( ) :
Returns the remainder of the division of numbers specified in the argument i.e.,
modules.
Syntax : Mod(<no1><no2>)
?Mod(10,30) output : 1 (remainder)
ABS ( ) : (Absolute)
Returns the absolute value of a numeric expressions.
Syntax : Abs(<number>)
Example : Abs(-60.34) output : 60.34
This function converts a negative value to positive. But has no effect on positive
numbers.
EXP ( ) :
Returns the ex value, where E represents a constant value of 2.718282
Syntax : Exp(<number>)
Example: ?Exp(1.0000) output : 2.718282
26
S. MADHU MOHAN FOXPRO
MAX ( ) :
Returns the maximum value of the given numbers.
Syntax : Max(<no1><no2>)
Example: ?Max(10,13) output : 13
MIN ( ) :
Returns the manimum value of the given numbers.
Syntax : Min(<no1><no2>)
Example: ?Min(10,13) output : 10
ROUND ( ) :
Rounds a number to the nearest decimal places specified.
Syntax : Round(<no1><no2>)
Example : ?Round(60.7389,2) output : 60.74
<no1> is the number to round and <no2> is the no of decimal places is round to.
SQRT( ) : (Squire Route)
Returns the squire route of the number passed to the function.
Syntax : Sqrt (<number>)
Example: ?Sqrt (625) output : 25
STRING Functions :
This functions are used to make manipulations on strings.
ASC( ) :
Returns the ASCII value of left, most character of any character string.
Syntax : ASC (<character>)
Example : ?Asc (“Amar”) output : A=65, a=97
?Asc(“S”) S=83, s=115
?Asc(“M”) M=77, m=109
AT ( ) :
Returns the starting position of one character string within another character
string.
Syntax : AT(<character1>,<character2>)
Example : AT(“SMM”,”M”) output : 2
CHR ( ) :
Returns the ASCII character for a number.
Syntax : CHR (<number>)
Example : ?CHR(65) output : A
27
S. MADHU MOHAN FOXPRO
ISALPHA( ) :
Determines whether the first character of a string is alphabet.
Syntax : ISALPHA (<character>)
Example : ?ISALPHA (“ABCDE1”) .T.
?ISALPHA (“124 ABC”) .F.
ISLOWER ( ) :
Determines whether the first character of a string is lower.
Syntax : ISLOWER (<character>)
Example : ISLOWER (“mOHAN”) .T.
ISLOWER (“Mohan”) .F.
STR ( ) :
Converts any numeric expression into a character string.
Syntax : STR (<number>),([,length>],[<decimal>])
Example : ?STR (1234.56) output : 1235 (10 characters wide)
?STR (1234.56,7,2) output : 1234.56 (7 characters wide)
LEFT ( ) :
Returns a specified no of characters, starting from the left most position of a
string.
Syntax : LEFT (<character>,<number>)
Example : ?LEFT (“INDIA”,3) output : IND
RIGHT( ) :
Returns a specified no. of characters, starting from the right most point in a
character expression.
Syntax : RIGHT(<character>,<number>)
Example : ?RIGHT (“INDIA”,3) output : DIA
LEN( ) :
Returns length of a character string i.e., total no. of characters.
Syntax ; LEN (<character>)
Example : ?LEN (“MADHU”) output : 5
LTRIM( ) : (Left Trim)
Removes leading blanks from a character string.
Syntax : LTRIM (<character>)
Example : ?LTRIM (“ Mohan”) output : Mohan
UPPER( ) :
Converts any character expression to upper case.
28
S. MADHU MOHAN FOXPRO
Syntax : UPPER (<character>)
Example : ?UPPWR (“mohan”) output : MOHAN
LOWER( ) :
Converts any character expression to lower case.
Syntax : L:OWER (<character>)
Example : ?LOWER (“MADHU”) output : madhu
SUBSTR( ) : (Sub String)
Substring function, extracts a smaller string from larger string.
Syntax : SUBSTR(<character>,<no1>,<no2>)
Example : ?SUBSTR(“ANDHRA PRADESH”,8,3)
Output : PRA
TRIM( ) :
Removes trailing blanks from a character string.
Syntax : TRIM (<character>)
Example : ?TRIM (“MOHAN “) output : MOHAN
VAL( ) :
Converts numbers stored as character strings to the numeric type.
Syntax : VAL (<character>)
Example : ?VAL (“1002.34”) output : 1002.34
OTHER FUNCTIONS :
BOF( ) : (Beginning of file)
Determines whether the beginning of file marker has been reached.
Returns .T. If the BOF occurred, otherwise .F.
Examples : Use mohan.dbf
?BOF()
Skip -1 .F.
?BOF() .T.
EOF( ) :
Determines whether the end of file marked (beyond) the last record has been
reached.
Returns .T. If the file pointer is at EOF, other wise .F.
Example : Use mohan.dbf or Modi comm. Mohan.prg
?EOF() – .F. Set talk off
Goto bottom Clear
Skip – 1 Use SMM
?EOF() – .T. Do while .NOT. EOF()
?name, no, total
Enddo
29
S. MADHU MOHAN FOXPRO
DBF( ) :
Returns the name of the currently selected data base file.
Example : Use mohan.dbf
?DBF() output : Student/mohan.dbf
DISK SPACE( ) :
Returns the no. of bytes available on the current working Disk Drive.
Syntax : Diskspace
Example : if(Diskspace>0)
? “Space is available”
Else
? “No Space”
Endif
FOUND( ) :
Determines the success of the commands, that were used to search for a
particular record.
Returns .T. If the most recently given search command is successful. Else .F.
Example : Use mohan.dbf
Name= “MADHU”
Seek= “Name”
?Found()
RECCOUNT( ) : (Record Count)
Returns the total no. of records in the currently selected data base file.
Example : ?RECCOUNT( )
REPLCIATE( ) :
Repeats a character string a specified no. of times.
Syntax : REPLICATE(<character>,<number>)
Example : ?REPLICATE(“*”,6) output : ******
SPACE( ) :
Creates a character string composed of a specified no. of blank.
Syntax : SPACE (<number>)
Example : ?”MADHU”+SPACE (2)+”MOHAN”
Output : MADHU MOHAN (madhu two spaces mohan)
VERSION( ) :
Returns the character expression containing the version no. of FoxPro in use.
30
S. MADHU MOHAN FOXPRO
Syntax : VERSION( )
Example : ?VERSION( )
Output : FoxPro 2.6 or Visual FoxPro 5.0
TEXT …. ENDTEXT :
The “Text…Endtext” command can be used to more off any block of the text for
display on screen or printer.
Syntax : Text <Text to be display>
Endtext
Example: TEXT
1. Adding New Employer
2. Deleting Employer
3. Editing Empoyer
4. Exit
ENDTEXT
STORE :
Store command is used assign values into one or more memory variables.
Syntax : Store <expre>to[<mem varia 1>][<mem varia 2>]
Examples : Store 1000 to Number
Store Krishna to Name
Store SQRT(25) to no
Store Replicate(“-“,80) to line
Store “Welcome”+” to India” to message
Store CTOD(“23/10/78”) to C_Date
Store CTOD_D_Date to Diff_Dates
Store 30+20 to no1, no2, no3.
22. Write a Program to accept a Customer name, meter no, present reading,
previous reading, unit cost. Find total units, bill amount.
Solution : MODI COMM ELECTRICITY.PRG
Set talk off
Clear
Store space(20) cname
Store 0 to mno,pre,prv,cost, tou,bill
@6,15 say “Enter Customer Name :” get name
@7,15 say “Enter Meter Number :” get mno
@8,15 say “Enter Present Reading :” get pre
@9,15 say “Enter Previous Reading :” get prv
@10,15 say “Enter Cost per Unit :” get cost
Tou=Pre – Prv
Bill=Tou*cost
@12,15 say “Total Number of Units :” get tou
31
S. MADHU MOHAN FOXPRO
@14,15 say “Total Bill Amount :” get bill
^w
23. Write a program to create a data base file with fields sno, sname, dos, unix,
total, average. create link dbf and prg files.
Solution : MODI COMM LINK.PRG Create Mohan.dbf
Set talk off sno n 5
Set safe off sname c 20
Clear dos n 3
Store “y” choice unix n 3
Use mohan.dbf total n 3
Store space(20) to name average f 5,2
Store 0 to no, m1,m2,tot,avg
Store Replicate(“-“,79) to line
Do while choice= “y”
Clear
@2,32 say “SMM COMPUTERS” colo *+g/w
@3,40 say “NANDIKOTKUR” colo *+r/w
@7,15 say “Enter Student Number :” get no
Read
Index on sno to no
Seek no
If found( )
Wait window “Student already exists”
Else
@8,15 say “Enter Student Name :” get name
@9,15 say “Enter Marks in Dos :” get m1
@10,15 say “Enter Marks in Unix :” get m2
Read
Tot=m1+m2
Avg=tot/2
@12,15 say “Total Marks :” +str(tot)
@12,15 say “Average Marks :’ +str(avg)
Endif
Append Blank
Replace sno with no
Replace sname with name
Replace dos with m1
Replace unix with m2
Replace total with tot
Replace average with avg
@20,15 say “Continue (Y/N0 :” get choice
Read
Clear
Enddo
^w
24. Write a program to accept student number. If number is not found display
message “no Not exists”. Else display name, word, excel, ppt, total, average.
32
S. MADHU MOHAN FOXPRO
Solution : MODI COMM STUDENT.PRG
Set talk off
Set safe off
Clear
Store “y” to choice
Use mohan.dbf
Store space(20) to name
Store 0 to no, m1,m2,tot,avg
Store Replicate(“*”,79) to line
Do while choice= “y”
Clear
@2,32 say “SMM COMPUTERS” colo *-
@3,40 say “NANDIKOTKUR” colo *-
@7,15 say “Enter Student Number :” get no
Read
Index on sno to no
Seek no
If .Not. Found() output :
Wait window “No Not Exists” Do Student
Else
@9,15 say “Student Name :” +sname Use mohan.dbf
@10,15 say “Marks in Oracle :” +str(oracle) list or F3
@11,15 say “Marks in VB :” +str(vb)
@12,15 say “Total Marks :” +str(total)
@13,15 say “Average Marks :” +str(average)
Endif
@20,15 say “Continue (Y/N) :” get choice
Read
Clear
Enddo
^w
25. Write a program to accept product number, pname, quantity, prate. Find bill.
If bill>500 discount=bill*15/100, else bill<500 discount=bill*5/100. replace all the
filedls with the product data base table.
Solution : MODI COMM PRODUCT.PRG CREATE PRODUCT.DBF
Set talk off pno n 5
Set safe off pname c 20
Clear quantity n 5
Store “y” to choice prate n 5
Do while choice= “y” bill n 5
Store space (20) to name discount n 5
Store 0 to no,qty,rate, bil, dis, nbill net bill n 5
Store Replicate(“=”,80) to line
Clear
@2,28 say “KAMADHENU SUPER MARKET” colo *-
@3,35 say “NANDIKOTKUR” colo *-
33
S. MADHU MOHAN FOXPRO
@4,28 say “-----------------------------------“ colo *-
@8,15 say “Enter Product Number :” get no
@10,15 say “Enter Product Name :” get name
@12,15 say “Enter Product Qunatity :” get qty
@14,15 say “Enter Product Rate :” get rate
Read
Bil=qty*rate
@16,15 say “Bill Amount :” get bil
If (bil>500)
Dis=bil*15/100
Else
If (bil<500)
Dis=bil*5/100
Endif
Endif
Nbil=Bil – Dis
@18,15 say “Total Bill amount :” get nbil
Use product.dbf
Append Blank
Repl pno with no
Repl pname with name
Repl quantity with qty
Repl prate with rate
Repl bill with bil
Repl discount with dis
Repl net bill with nbill
@20,15 say “Continue (Y/N) :” get choice
Read
Clear
Enndo
^w
26. Write a program to accept a number find whether the number is “prime
number or not”.
Solution : MODI COMM PRIME.PRG
Set talk off
Set safe off
Clear
Store 0 to no, B
I=1
Store Replicate(“chr(3)”,40) to line
@5,35 say “Finding Prime Number”
@6,30 say “------------------------------“
@8,25 say “Enter a Number :” get no
Read
Do while (i<=no)
If(mod(n,i)=0)
B=B+1
34
S. MADHU MOHAN FOXPRO
Endif
I=I+1
Enddo
If(B<=2)
@10,25 say “PRIME NUMBER” +str(no)
Else
@10,25 say “NOT PRIME NUMBER” +str(no)
Endif
^w
27. Write a program to find a string is Palindrome or not.
Solution : MODI COMM PALINDROME.PRG
Set talk off
Clear
Store space(20) to string, rstring
@5,20 say “Enter String Name :” get string output :
Read Do Palindrome
Length=len(string) Madhu Mohan
P=1 Not palindrome
Do while(p<length)
Rstring=substr(string,p,1)+rstring Liril
P=p+1 Palindrome
Enndo
If Ltrim(rstring)=Ltrim(string)
@7,20 say “This is Palindrome”
Else
@7,20 say “This is not Palindrome”
Endif
^w
28. Write a program to find palindrome number or not.
Solution : MODI COMM PALINDROM.PRG
Set talk off
Clear
Store 0 to no, r, reverse, m
@5,15 say “Enter Any Numebr :” get no
Read
I=1 output :
M=no palindrome numbers
Do while(I<=no) 1,2,3,……….9,11
R=mod(no,10)
Reverse=(reverse*10)+R Not palindrome numbers
No=Int(no/10) 10,12,13,199.
I=I+1
Enddo
If (reverse=M)
@6,15 say “Palindrome Number”
Else
35
S. MADHU MOHAN FOXPRO
@6,15 say “Not Palindrome Number”
Endif
29. Write a program to handling two data base files.
Solution : STD_ADDRESS.DBF STD_MARKS.DBF
Sno n 4 sno n 4
Address1 c 20 sname c 20
Address2 c 20 foxpro n 3
Scourse c 10 internet n 3
Total n 3
Average f 5,2
MODI COMM MOHAN.PRG
Set talk off
Set safe off
Clear
Close all
Use Std_marks
Index on sno to no
Select B
Use Std_address
Select A
Index on sno to no
Store “y” to choice
Store 0 to no, m1, m2, tot, avg
Store space(20) to name, add1, add2, course
Do while choice= “y”
@2,32 say “SMM COMPUTERS” colo *+gb/w
@3,40 ssay “NANDIKOTKUR” colo *+gr/w
@4,32 say Replicate(“chr(7),80) colo *+r/w
@7,15 say “Enter Student Number :” get no
Read
Seek no
If Found()
Wait window “Number Exists” +no or (name)
Else
@8,15 say “Enter Student Name :” get name
@9,15 say “Enter FoxPro Marks :” get m1
@10,15 say “Enter Internet Marks :” get m2
@11,15 say “Enter Course Name :” get course
@12,15 say “Enter Area Name :” get add1
@13,15 say “Enter Village Name :” get add2
Read
Tot=m1+m2
Avg=tot/2
@15,15 say “Total Marks :” +str(tot)
@17,15 say “Average Marks :” +str(avg)
Append Blank
36
S. MADHU MOHAN FOXPRO
Repl sno with; repl sname with name; repl foxpro with m1;
repl internet with m2; repl total with tot; repl average with avg
Select B
Append Blank
Repl sno with no; repl address1 with add1;
Repl address2 with add2; repl scourse with course
Endif
@18,15 say “---------------------------------------“
@20,25 say “Continue (Y/N) :” get choice
Read
Clear
Enddo
^w
30. Write a program to display ASCII characters of given numbers.
Solution : MODI COMM ASCII.PRG
Set talk off
Clear
Store 0 to no
@5,15 say “Enter Any Number :” get no
Read
K=chr(no)
?k
^w
31. Write a program to print ASCII numbers.
Solution : MODI COMM ASCII.PRG
Set talk off
Clear
Store space(1) to A
@5,15 say “Enter a character :” get A
Read
K=Asc(A)
?K
^w
32. Write a program to print a string this format.
Solution : MODI COMM STRING.PRG output :
Set talk off Do string
Set clock on M
Clear MO
M=1 MOH
Store space(20) to string MOHA
@5,15 say “Enter String Name :” get string MOHAN
Read | ?left(string,m)
L=Len(string) | m=m+1
Do while(M<=L) | enddo
37
S. MADHU MOHAN FOXPRO
33. Write a program to print reverse of given numbers.
Solution : MODI COMM REVERSE.PRG
Set talk off
Clear
Store 0 to no, I, reverse
@5,15 say “Enter any number :” get no
Read
P=1 output :
Do while (p<=no) Do Reverse
I=mod(no,10) Enter number : 199
Reverse=((reverse*10)+I) 199 : 991
No=int(no/10)
Enddo
?reverse
^w
34. Write a program to print reverse of of A.B.( A value=B, B value=A).
Solution : MODI COMM MADHU.PRG
Set talk off
Clear Do madhu
Input “A value :” to A A value : 25
Input “B value :” to B B value : 50
? “A value :”, B output :
? “B value :” A A value : 50
Set talk on B value : 25
^w
35. Write a program to print n numbers, and print average of n numbers.
Solution : MODI COMM AVERAGE.PRG
Set talk off
Clear
A=1
Tot=0
Input “How many number :” to n
Do while(a<=n)
Input “x=” to x
Tot=tot+x
A=a+1
Enndo
Avg=tot/n
? “Average of numbers :”, avg
Set talk on
^w
36. Write a program to Armstrong number or not.
Solution : MODI COMM ARMSTRONG.PRG
Set talk off
38
S. MADHU MOHAN FOXPRO
Clear
Store 0 to no
@5,15 say “Enter any number :” get no
Read
X=no
Arm=0
Do while(no=0)
Rem=mod(no,10)
Arm=arm+rem+rem
No=Int(no/10)
Enddo
If x=Arm
@7,20 say “Armstrong Number”
Else
@7,20 say “Not Armstrong Number”
Endif
^w
37. Write a program to print inverse pyramid format.
Solution : MODI COMM PYRAMID.PRG
Set talk off
Clear
Row=5
Column=5
C=15
For I=10 to 1 step -1
For J= I to 1 step -1
@row,column say Ltrim(str(J))
Column=column+4
Endfor
Row=row+1
C=c-2
Column=c
@20,6 say “MOHAN”
Endfor
^w
38. Write a Program to print concentric boxes.
Solution : MODI COMM BOXES.PRG
Set talk off
Clear
Set colo to *-
R1=0
R2=24
C1=0
C2=79
Do while(R1<=12)
@r1,c1 to r2,c2 double
39
S. MADHU MOHAN FOXPRO
R1=r1+1
C1=c1+1
R2=r2-1
C2=c2-1
Enddo
@3,25 say “HELLO! GOOD MORNING” colo w/rb++
@6,20 say “MADHU MOHAN” colo w/gr++
^w
39. Write a program to accept a number. If number exists in bdf file, display his
name and course.
Solution : MODI COMM MOHAN.PRG
Choice= “y”
Do while choice= “y”
Set talk off
Set clock on
Set safe off
Clear
Store 0 to no
Store space (1) to c
Use mohan.dbf
Index on sno to no
@8,15 say “Enter number to Delete :” get no
Read
Seek no
If Found()
@10,15 say “Student Name :” +name
@12,15 say “Course Name :” +course
@14,15 say “Balance Fee :’ +str(balance)
@16,15 say “Do you want to delete :” get c
Read
If c= “y”
Locate for sno=no
Delete
Pack
Endif
Else
Wait window “Number not exists”
Endif
@20,20 say “Continue (Y/N) :” get choice
Read
Clear
Enddo
^w
40
S. MADHU MOHAN FOXPRO
ARRAYS
An array is a series of memory variables containing related data. The memory
variable has a subscript number to identify individual elements. A single dimensional
array contains a row or column of elements, but a two dimensional array contains
values in cells made of several rows and columns.
DECLARE / DIMENSION :
Any of the two commands can be used to create an array.
Dimension / Declare is used to declare an array.
OBF( ) -----
COUNT( ) -----
Copy to Array <Array name>
This command copies the records from the data base file to the array whose
names specified.
Single Dimension Array :
A single dimension array contains row or column of elements. But a two
dimensional array contains values in cells made of several rows and columns.
40. Write a program to accept 10 values to an array and print them.
Solution : MODI COMM ARRAY.PRG
Set talk off
Clear
I=1
Dimension A(10)
For I=1 to 10
Input “Enter Value :” to A(I)
Endfor
?
?
For I=1 to 10
? A(I)
Endfor
^w
ARRAY FUNCTIONS
ASCAN( ) :
This function does the search operation by using the array name and the value to
search for as parameters. It returns row number in which the value exists and returns
zero, if search is unsuccessful.
41
S. MADHU MOHAN FOXPRO
ALEN( ) :
Returns the length of an array. The optional (<expre>) expression is an number
between 0 to 1.
0 – number of element in the array.
1 – returns no of rows.
2 – returns no of columns.
Syntax : ALEN(array name[<expre>])
Example : ALEN (A(5,2))
ADEL( ) :
This function deletes values from on array.
Syntax : ADEL (array name [<expr>][,(2)])
<expr> denotes the row number of the column number to dleted.
ASORT( ) :
This function sorts on array in the ascending order by default.
Syntax : ASORT(array name[expr n1, expr n2, expr n3]]])
<expr n1> denotes the row to start sorting from.
<expr n2> denotes no of rows to sort.
<expr n3> denotes the number 0 or 1.
To start an ascending or descending order.
Example : ASORT (ABC,2,9,1) 2 – starting row
9 – no. of rows
1 – descending order.
ACOPY( ) :
Copies contents of the array1 to array2. if array 2 does not exists, it creates an
array with same dimensions as array 1.
Syntax : ACOPY (array1, array 2)
41. Write a program to accept 5 values. Find the numbers are “even or odd” and
print sum of even or odd.
Solution : MODI COMM SMM.PRG
Set talk off
Clear
Store 0 to I, evensum, oddsum, test, E, O
Declare A(5)
For I=1 to 5 step 1
Input “Enter values :” to A(I)
Endfor
For I=1 to 5 step 1
42
S. MADHU MOHAN FOXPRO
Test=Mod(a(I),2)
If test=0 Do Number
E=E+1 Enter value : 2,4,9,44,99
Evensum=evensum+A(I) output :
Else Even Nos=3(2,4,44)
O=O+1 Evensum=50(2+4+44)
Oddsum=oddsum+A(I)
Endif Odd Nos=2(9,99)
Endfor Oddsum=108(9+99)
? “Even Numbers :”, E
? “Sum of Even Numbers :”, evensum
? “Odd Numbers :”, O
? “Sum of Odd Numbers :”, oddsum
^w
42. Write a program to accept 5 numbers. Find big number and small number
from given number.
Solution : MODI COMM BIG.PRG
Set talk off
Clear
Declare A(5)
Store 0 to I,big,small
For I=1 to 5
Input “Enter Numbers :” to A(I)
Endfor
Small=A(I)
For I=1 to 5 Do Big
If A(I)> big Enter Numbers :
Big=A(I) 2,4,9,44,99
Endif
Endfor Big Number : 99
For I=1 to 5 Small Number : 2
If A(I)<small
Small=A(I)
Endif
Endfor
? “Big Number :”, big
? “Small Number :”, small
^w
43. Write a program to multiplication of matrix.
Solution : MODI COMM MATRIX.PRG
Set talk off
Clear
Dimension A(2,2), B(2,2), C(2,2)
Store 0 to I, J
For I= 1 to 2
43
S. MADHU MOHAN FOXPRO
For J= 1 to 2
Input “Enter 1st
Matrix values :” to A(I,J)
* Next J
Endfor Do Matrix
* Next I 1st
matrix :
Endfor 3,4,5,2
For I=1 to 2
For J=1 to 2 2nd
matrix :
Input “Enter 2nd
Matrix values :” to B(I,J) 6,12,6,7
Endfor
Endfor 3*6 4*12
? 5*6 2*7
?
? “Multiplication of Matrix” 18 48
For I= 1 to 2 30 14
For J= 1 to 2
C(I,J)=A(I,J)*B(I,J) output :
??C(I,J) 18,40,30,14
Endfor
Endfor
^w
44. Write a program to accept name, no, course, fees, paid. Find balance and link
program file.
Solution : MODI COMM SMM.PRG CREATE FEES.DBF
Set talk off name c 20
Set safe off number n 5
Clear course c 8
Store 0 to no, feepay fee n 8
Store “y” to choice, option paid n 8
Do while option= “y” balance n 8
Use fees.dbf
Index on sno to no
@5,20 say “Enter Student Number :” get no
Read
Seek no
If Found()
@7,20 say “Student Name :” +name
@8,20 say “Course Name :” +course
@9,20 say “Actual Fee :” +str(fee)
@11,20 say “Do you want to pay fee (Y/N) :” get choice
Read
If choice= “y”
@16,20 say “Enter Fee Paying :” get feepay
Read
Repl paid with paid+feepay
Repl balance with balance – feepay
Endif
44
S. MADHU MOHAN FOXPRO
Else
Wait window “Number not exists”
Endif
@20,20 say “Do you want to continue (Y/N) :” get option
Read
Clear
Enddo
^w
45. Write a program to accept your name and display in ASCII values.
Solution : MODI COMM SMM.PRG
Set talk off
Clear
Store 0 to L,A
Accept “Enter any Name :” to name
L=Len(name) Do smm
For A= 1 to L Enter name : MADHU
L=substr(name,A,1)
?C=ASC(C) output
Endfor 77,65,67,72,85
^w
46. Write a program to accept employee number, name, designation, salary.
Calculate bonus by manager=20%, accountant=!5% on salary, clerk=1000 rs,
others=600 rs.
Solution : MODI COMM BONUS.PRG CREATE BONUS.PRG
Set talk off eno n 5
Set safe off ename c 20
Set colo on designation c 15
Set echo off salary n 6
Clear bonus n 6
Store “y” to choice netsalaray n 10
Do while choice =”y”
Store 0 to no, sal, bon, netsal
Store space(20) name, desig
Clear
@2,30 say “BUSINESS MANAGEMENT”
@3,37 say “NANDIKOTKUR”
@4,30 say “------------------------------------“
@6,15 say “Enter Employee Number :” get no
@8,15 say “Enter Employee Name :” get name
@10,15 say “Enter Designation :” get design
@12,15 say “Enter Basic Salary :” get sal
Read
If desig= “manager”
Bon=sal*20/100
Else
45
S. MADHU MOHAN FOXPRO
If design= “accountant”
Bon=sal*15/100
Else
If desig= “clerk”
Bon=1000
Else
If design= “others”
Bon=600
Endif
Endif
Endif
Endif
@15,15 say “Bonus Amount :” get bon
Netsal=sal+bon
@18,15 say “Net salary :” get netsal
Use bonus.dbf
Append Blank
Repl eno with no; repl ename with name; repl designation with design;
Repl salary with sal; repl bonus with bon; repl netsalary with netsal
@20,20 say “Do you want to continue (Y/N) :” get choice
Read
Clear
Enddo
^w
BOX :
Draws a box using specified co-ordinates.
Syntax : @<row1>,<column1>,<row2>,,colimn2> box
<expr c> expression of character.
Example : Box program
Modi comm. Box.prg
Set talk off
Clear
@3,24, 6,52 box
@4,26 say “SMM COMPUTERS” colo *rg/b+
@5,34 say “NANDIKOTKUR” colo *rg/b+
^w
Examples: @10,20 , 12,20 box replicate(chr(22),9)
@3,24, 6,52 box “*”
@16,24, 18,52 box *
@3,24 , 6,52 box replicate(190),2
@3,22 to 6,53 double colo *gr/o+
DOUBLE :
If double is included, the box is drawn with a double line border.
46
S. MADHU MOHAN FOXPRO
Example : modi comm. Double.prg
Set talk off
Clear
@3,22 to 6,53 double colo +rb/b*
@4,26 say “SMM COMPUTERS”
@5,34 say “NANDIKOTKUR”
^w
PANEL :
“Panel” is included, the box is drawn with a solid border.
Example : modi comm. Panel.prg
Set talk off
Clear
@3,22 to 6,53 panel
@4,26 say “SMM COMPUTERS”
@5,34 say “NANDIKOTKUR”
^w
47. Write a program display the menu bar.
Solution : MODI COMM MENU.PRG
Set message to 23 center
Set talk off
Define menu “SMM”
Define pad pad1 of smm prompt “File” at 11,7
On pad pad1 of smm activate popup pop1
Define popup pop1 from 1,1 to 6,14 (or) 12,15 to 16,14
Define bar1 of pop1 prompt “<NEW”
Define bar2 of pop1 prompt “<OPEN”
Define bar3 of pop1 prompt “<SAVE”
Define bar4 of pop1 prompt “E<XIT”
On selection bar1 of pop1 do mm1
On selection bar2 of pop1 do mm2
On selection bar3 of pop1 do mm3
On selection bar4 of pop1 do mm4
Activate menu smm
^w
48. Write a program display the menu bar.
Solution : MODI COMM MENU.PRG
Set talk off
Define menu “SMM”
Define pad pad1 of smm prompt “ST<UDENT” colo +rb/gr+
Define pad pad2 of smm prompt “<FEES” colo +rb/gr+
Define pad pad3 of smm prompt “<DELETE” colo +rb/gr+
47
S. MADHU MOHAN FOXPRO
On pad pad1 of smm activate popup pop1
On pad pad2 of smm activate popup pop2
On pad pad3 of smm activate popup pop3
Define popup pop1
Define popup pop2
Define popup pop3
Define bar1 of pop1 prompt “<ADD”
Define bar2 of pop1 prompt “<OPEN”
Define bar3 of pop1 prompt “E<XIT”
Define bar1 of pop2 prompt “<PAYMENTS”
Define bar2 of pop2 prompt “<TOTAL FEES”
Define bar1 of pop3 prompt “<STUDENT”
On selection bar1 of pop1 do mm1
On selection bar2 of pop1 do mm2
On selection bar3 of pop1 do mm3
On selection bar1 of pop2 do mm4
On selection bar2 of pop2 do mm5
On selection bar1 of pop3 do mm6
Activate menu smm
^w
49. Write a program to print concentric box.
Solution : MODI COMM CONENTRIC.PRG
Set talk off
Clear
Set colo to gr
R=1
C=30
Do while R<8
@R,C say “*”
R=R+1
C=C-2
Enddo
R=18
C=17
Do while R<16
@R,C say “*”
R=R+1
C=C+2
Enddo
R=1
C=30
Do while R<8
48
S. MADHU MOHAN FOXPRO
@R,C say “*”
R=R+1
C=C+2
Enddo
R=8
C=43
Do while R<16
@R,C say “*”
R=R+1
C=C-2
Enddo
R=1
C=30
Do while R<8
@R,C say “*”
R=R+1
C=C-2
Enddo
Set colo to
Set colo to rb+*
@8,25 say “SMM COMPUTERS”
Set colo to
^w
50. Write a program to accept cname, no, code, item, weight, rate, quantity. Find
total, discount, netbill.
Solution : MODI COMM AGRI.PRG
Set talk off
Set safe off
Set colo on
Clear
T=time()
@4,15 say t colo +gr/b
D=date()
@4,60 say d colo +gr/b
Choice= “y”
Do while choice= “y”
Clear
Store space(20) to cname
Store space(12) to item
Store 0 to no, code, weight, rate, quantity, total, discount, net_bill
@1,1 to 23,77 chr(3) colo +g/w+
@2,25 to 7,58 double
@3,30 say “AGRI GOLD FORMS LIMITED” colo gr+
@4,31 say “SUPER MARKET DIVISION” colo rb+
@5,32 say “NANDYAL ROAD, KURNOOL” colo r+
@6,37 say “CASH – MEMO” colo bg+
@13,3 get no
49
S. MADHU MOHAN FOXPRO
Read
@12,16 say “Code :” colo g+
@13,16 get Code
Read
@12,28 say “Item :” colo g+
@13,28 get Item
Read
@12,42 say “Weight :” colo g+
@13,42 get Weight
Read
@12,54 say “Rate :” colo g+
@13,54 get Rate
Read
@12,65 say “Quantity :” colo g+
@13,65 get Quantity
Read
Total=rate*quantity
If(total>1500)
Discount=total*20/100
Else
If (total>1000 .and. total<1500)
Discount=total*10/100
Else
Discount=0
Wait window “No Discount”
Endif
Endif
@14,65 to 14,74
@15,30 say “Total :” colo g+
@15,60 say Total
@16,30 say “Discount :” colo g+
@16,60 say Discount
@17,65 to 17,74
Net_bill=total-discount
@18,53 say “Net Bill ……… :” +str(net_bill) colo +g/r
@21,46 say “Continue (Y/N) :” get choice colo gb+
Read
Clear
@21,15 say “Thank You Visit Again” colo gr+
Enddo
^w
51. Write a program to simple designing.
Solution : MODI COMM DESIGN.PRG
Set talk off
Clear
Row=4
Column=8
50
S. MADHU MOHAN FOXPRO
C=8
For I=18 to 1 step -1
For J= I to 1 step -1
@row,column say ltrim(str(J))
Column=column+1
Endfor
Row=row+1
C=c+2
Column=c
Set colo to gr++
@24,6 say “SMM COMPUTERS”
Set colo to
Endfor
^w
52. Write a program for simple designing.
Solution : MODI COMM DESIGN.PRG
Set talk off
Clear
Set colo to r+*
@11,1, 15,79 box*
Set colo to +g/b*
@13,35 say “MADHU MOHAN”
@13,33 say chr(3)
@13,47 say char(3)
@2,32 to 24,48 colo r*
R=1
C=40
Do while R<=12
@R,C say chr(3) colo gr+*
R=R+1
C=C-3
Enddo
R=13
C=4
Do while R<=24
@R,C say chr(3) colo gr+*
R=R+1
C=C+3
Enddo
R=14
C=73
Do while R<=24
@R,C say chr(3) colo gr+*
R=R+1
C=C-3
Enddo
R=1
C=40
51
S. MADHU MOHAN FOXPRO
Do while R<=13
@R,C say chr(3) colo gr+*
R=R+1
C=C+3
^w Enddo
53. Write a program to calculations of the simple interest, squire root, product,
eligible vote.
Solution : MODI COMM MADHU.PRG
Set talk off
Set safe off
Clear
Option= “y”
Do while option= “y”
Ch=0
Text
CALCULATIONS
1. Simple Interest
2. Squire Root
3. Product
4. Person Eligible for Vote
5. Exit
Endtext
@9,15 say “Enter your choice :” get ch colo gr/b+*
Read
Do case
Case ch=1
Set talk off
Store 0 to P,T,R, amount
@11,15 say “Enter Principle Amount :” get P
@12,15 say “Enter Time :” get T
@13,15 say “Enter Interest Rate :” get R
Read
Amount=P*T*R/100
@14,15 say “Total Amount :” +str(amount)
Case ch=2
No=0
@11,15 say “Enter any number :” get N
Read
R=N*N
@12,15 say “Squire Root value :” +str(R)
Case ch=3
Store 0 to N,M,R
@11,15 say “Enter First Number :” get N
@12,15 say “Enter Second Number :” get m
52
S. MADHU MOHAN FOXPRO
Read
R=N*M
@14,15 say “Product Result :” =str(R)
Case ch=4
Store 0 to age
@11,15 say “Enter Voter Age :” get age
Read
If age<18
@13,15 say “You are not Eligible for Vote”
Else
@13,15 say “You are Eligible for Vote”
Endif
Otherwise
Wait window “Thank you”
Exit
End case
@20,15 say “Do you want to continue (Y/N) :” get option
Read
Clear
Enddo
^w
54. Write a program to accept a number. Find factorial value of given number.
Solution : MODI COMM FACTORIAL.PRG
Set talk off
Clear
Fact=1
Input “Enter a number :” to N
For I= to N
Fact=fact*I
?Fact
Endfo
^w
55. Write a program to print multiplication tables.
Solution : MODI COMM MULTIPLICATION.PRG
Set talk off
Set safe off
Clear
Store 0 to N
@5,10 say “Enter a number :” get N
Read
M=1
Do while m<=n
I=1
Do while I<=10
R=M*I
53
S. MADHU MOHAN FOXPRO
?M, “X”, I, “=” R
Read
I=I+1
Enddo | M=M+1
Clear | Enddo
Read | ^w
56. Write a program to accept a number to converted string.
Solution : MODI COMM CONVERT.PRG
Set talk off
Set safe off
Store “ ” to J,S
Store 0 to A, I
Clear
Accept “Enter a number :” to N
L=Len(N)
For I=1 to L
J=substr(N,I,1)
If J= “1”
S=s+ “one”
Else
If J= “2”
S=s+ “two”
Else
If J= “3”
S=s+ “three”
Else
If J= “4”
S=s+ “four”
Else
If J= “5”
S=s+ “five”
Else
If J= “6”
S=s+ “six”
Else
If J= “7”
S=s+ “seven”
Else
If J= “8”
S=s+ “eight”
Else
If J= “9”
S=s+ “nine”
Else
If J= “0”
S=s+ “zero”
Endif
Endif
54
S. MADHU MOHAN FOXPRO
Endif Endif
Endif Endfor
Endif ^w
Endif
Endif output :
Endif Enter number : 23
Endif Two three
57. Write a program to accept product name, manufacturing date, product price,
local tax. Find selling price, profit.
Solution : MODI COMM PRODUCT.PRG
Set talk off
Set safe off
Clear
Ch= “y”
Do while ch= “y”
Clear
Store space(15) to pname
Store space(8) to date
Store 0 to price, tax, sp, pro, np
Store space(1) to choice
@3,3 to 9,60 double
@5,10 say “Enter Product Name :” get pname
@6,10 say “Enter Manufacturing Date :” get date
@7,10 say “Enter Actual Price :” get price
@8,10 say “Entre Local Tax :” get tax
Read
Sp=price+tax
Pro=tax
@10,10 say “Product Name :” +pname
@11,10 say “Manufacturing Date :” +date
@12,10 say “Actual Price :” +str(price)
@13,10 say “Local Tax :” +str(tax)
@14,10 say “Selling price :” +str(sp)
@15,10 say “Profit Amount :” +str(pro)
Np=np+pro
@17,10 say “Net profit :” +str(np)
@18,10 say “Do you want to continue (Y/N) :” get ch
Read
Clear
Enddo
^w
58. Write a program to accept a exponent number.
Solution : MODI COMM EXPONENT.PRG
Set talk off
Set safe off
Clear
55
S. MADHU MOHAN FOXPRO
Store 0 to N, E
Input “Enter Your Number :” to N
Input “Enter Your Exponent Number :” to E
A=1
B=N
Do while a<E Enddo
N=N*B ? “Your Number is ……”, to N
A=A+1 ^w
59. Write a program to calculate the results of “n” number of students.
Solution : MODI COMM SMM.PRG
Set talk off
Set safe off
Clear
Store 0 to M
@10,15 say “Enter a Number :” get M
Read
A=1
Do while a<=M
Store 0 to m1,m2,tot,avg
Store space(20) to name
@12,15 say “Name of the Student :” get name
@13,15 say “Enter Marks in FoxPro :” get m1
@14,15 say “Enter Marks in Internet :” get m2
Read
A=a+1
Clear
Tot=m1+m2
Avg=tot/2
@13,15 say “Name of the Student :” get name
@14,15 say “Enter Marks in FoxPro :” get m1
@15,15 say “Enter Marks in Internet :” get m2
@17,10 to 23,50 panel colo g+/r+*
@19,20 say “Total Marks : get tot
@20,20 say “Average Marks :” get avg
Wait “SMM COMPUTERS”
Clear
Enddo
^w
60. Write a program to print a diagram of “Robot” and using special characters.
Solution : MODI COMM ROBOT.PRG
Set talk off
Set safe off
Clear
Do while .T.
Close all
Clear all
@2,25 tp 6,35
56
S. MADHU MOHAN FOXPRO
Set colo to /w*
@4,28 say “♥”
@4,32 say “♥”
Set colo to r+/b+
@5,30 say “↔↔”
Set colo to
@7,29 say “ ”
@8,22 to 15,38
Set colo to r++
@15,23 say “«»«»«»«»«»«»«»«»”
Set colo to
@9,30 to 14,30
@15,22 to 22,26
@15,34 to 22,38
@22,22 say “∇∇∇∇”
@22,34 say “∇∇∇∇”
@1,26 say “¥”
@1,33 say “¥”
@2,26 say “¥”
@1,33 say “¥”
@8,38 to 13,42
@13,39 say “п п п”
@8,18 to 13,22
@13,19 say “п п п”
Store 0 to A
Set colo to g++
Store “HAPPY BIRTH DAY TO U” to N
L=Len(N)
Do while A<=L
@5,36 say left(N,A)
?chr(7)
A=A+1
Enddo
Set colo to
****************
@9,39 clear to 14,45
@5,36 clear to 5,65
@8,38 to 9,50
@8,51 say “≡”
@9,51 say “≡”
Store 0 to A
Set colo to gr++
Store “HAPPY NEW YEAR WISHES TO U” to N
L=len(n)
Do while A<=L
@9,53 say left(N,A)
57
S. MADHU MOHAN FOXPRO
?chr(7)
A=A+1
Enddo
Set colo to
****************
@,39 clear to 9,76
@15,40 clear to 15,75
@3,37 to 8,41
@3,38 say “±±±”
Store 0 to A
Set colo to bg++
Store “HELLO, I AM MADHU’S HELPER” to N
L=len(N)
Do while A<=L
@2,43 say left(N,A)
?chr(7)
A=A+1
Enddo
Set colo to
****************
@2,40 clear to 2,75
@3,37 clear to 8,50
Clear
Enddo
Set colo to
^w
61. Write a program to designing.
Solution : MODI COMM DESIG.PRG
Set talk off
Set safe off
Clear
Store 10 to N
Set colo to w*/b+
R1=2
C1=15
R2=22
C2=60
Do while n>=6
@R1,C1,R2,C2
R1=R1+2
C1=C1+5
R2=R2-2
C2=C2-5
N=N-1
Enddo
Set colo to r*/w+
@12,27 say “SMM COMPUTERS” colo g+/gr++
58
S. MADHU MOHAN FOXPRO
^w
62. Write a program to accept principle, time, rate. Find interest.
Solution : MODI COMM INTEREST.PRG
Set talk off
Set safe off
Clear
Store 0 to P, T, R
Input “Enter Principle :” to P
Input “Enter Time :” to T
Input “Enter Rate :” to R
SI=P*T*R/100
@15,20 say “Interest Amount :” get si
^w
63. Write a simple program.
Solution : MODI COMM MADHU.PRG
Set talk off
Clear
Store 0 to I,N
Accept “Enter any message :” to mess
Input “Enter you limit :” to N
? “S R A A C LTD”
Do while I<N
?mess
I=I+1
Enddo
? “Thank you”
^w
64. Write a simple program.
Solution : MODI COMM MOHAN.PRG
Set talk off
Clear
Store 0 to M,N
Input “Enter any number :” to M
Input “Enter another number :’ to N
Do while M=>N
If M%2=0
?M
Endif
M=M-1
Enddo
^w
65. Write a simple program.
Solution : MODI COMM SMM.PRG
59
S. MADHU MOHAN FOXPRO
Set talk off
Clear
Input “Enter Your Limit :” to N
I=1
Sum=0
Do while I<=N
Input “Enter a Number :” to A
Sum=sum+A
I=I+1 ? “The average is :”, average
Average=sum/N Enddo
? “The sum of N is :”, sum ^w
66. Write a simple program.
Solution : MODI COMM MOHAN.PRG
Set talk off
Clear
Store 0 to N,M
Input “Enter any two numbers :” to N,M
Your no :” to N
Do while N<=100
? N
N=N+1
Enddo
^w
68. Write a designing program.
Solution : MODI COMM DESIGN.PRG
Set talk off
Clear
Row=2
Column=8 output :
C=8 5 4 3 2 1
For I=20 to 1 step -1 4 3 2 1
For J= I to 1 step -1 3 2 1
@row, column say ltrim(str(J)) 2 1
Column=column+2 1
Endfor
Row=row+1
C=c+2
Column=c
Endfor
^w
69. Write a program for the required format.
Solution : MODI COMM DESIGN.PRG
Set talk off
Clear
Row=2
60
S. MADHU MOHAN FOXPRO
Column=8 output :
C=8 5 4 3 2 1
For I=18 to 1 step -1 4 3 2 1
For J= I to 1 step -1 3 2 1
@row, column say ltrim(str(J)) 2 1
Column=column+2 1
Endfor
Row=row+1
C=c+4
Column=c
Endfor
^w
70. Write a program to print a name that 200 times.
Solution : MODI COMM NAME.PRG
Set talk off
Set safe off
Clear
For I=1 to 20
For J=1 to 40
For k=1 to 200
?? “SMM COMPUTERS”
Endfor
Endfor
Endfor
^w
71. Write a program to accept cname, mno, pre, prv, total units, bill amount. If
total units>=400 amount 6/- , tu>=300 and tu<400 amount=5/-, tu>=250 and
tu<300 amount=4/-, tu>=200 and tu<250 amount=3/-, tu>=150 and tu<200
amount=2/-, tu>=100 and tu<150 amount=1.50/-, tu<=100 amount=1/-.
Solution : MODI COMM METER.PRG
Set talk off
Clear
Accept “Enter Customer Name :” to cname
Input “Enter Meter Number :” to mno
Input “Enter Present Reading :” to pre
Input “Enter Previous Reading :” to prv
Tu=pr-pv
If(tu>=400)
Bill=tu*6
? “Number of Units :”, tu
? “Total Bill Amount :”, bill
Else
If(tu>=300 .and. tu<400)
Bill=tu*5
? “Number of Units :”, tu
? “Total Bill Amount :”, bill
61
S. MADHU MOHAN FOXPRO
Else
If(tu>=250 .and. tu<300)
Bill=tu*4
? “Number of Units :”, tu
? “Total Bill Amount :”, bill
Else
If(tu>=200 .and. tu<250)
Bill=tu*3
? “Number of Units :”, tu
? “Total Bill Amount :”, bill
Else
If(tu>=150 .and. tu<200)
Bill=tu*2
? “Number of Units :”, tu
? “Total Bill Amount :”, bill
Else
If(tu>=100 .and. tu<150)
Bill=tu*1.50
? “Number of Units :”, tu
? “Total Bill Amount :”, bill
Else
If(tu<300)
Bill=tu*1
? “Number of Units :”, tu
? “Total Bill Amount :”, bill
Else
Endif
Endif
Endif
Endif
Endif
Endif
Endif
Set talk on
^w
71. Write a program to accept population. Popu>=100000000, country;
popu>=10000000 .and. popu<100000000, state; popu>=500000 .and.
popu<1000000, district; popu>=50000 .and. popu<100000, taluq; popu>=5000
.and. popu<50000, mandal, otherwise village.
Solution : MODI COMM POPULATION.PRG
Set talk off
Clear
Input “Enter Total No. of Population :” to po
If(po>=100000000)
? “Country :”, po
Else
If(po>=10000000 .and. po<100000000)
62
S. MADHU MOHAN FOXPRO
? “State :”, po
Else
If(po>=100000 .and. po<1000000)
? “District :”, po
Else
If(po>=50000 .and. po<100000)
? “Taluk :”, po
Else Endif
If(po>=5000 .and. po<50000) Endif
? “Mandal :”, po Endif
Else Endif
? “Village :”, po Set talk on
Endif ^w
72. Write a program to print Students application.
Solution : MODI COMM APPLICATION.PRG
Set talk off
Clear
Accept “Enter Application Number :” to AN
Accept “Enter Student Name :” to snmae
Accept “Enter Father Name :” to fname
Accept “Enter Your Address :” to add
Accept “Enter Your Date of Birth :” to dob
Accept “Enter Qualificaiton :” to qua
Accept “Enter Course Name :” to cou
Accept “Enter Fees :” to fee
Accept “Enter Date of Joining :” to date
Accept “Enter Place :” to pla
Clear
@2,3 to 24,60 double colo g+/r
@3,19 say “SMM COMPUTERS” colo gr+
@4,12 say “Near College Road, NANDIKOTKUR – 518401” colo rb/i
@5,4 say “--------------------------------------------------“ colo r+
@6,5 say “App no :” get an colo w+/br
@6,45 say “Fee :” get fee colo w+/br
@7,49 to 11,58
@9,50 say “Photo” colo gr+/b
@8,4 say “1. Name of the Student :” get sname
@9,4 say “2. Father’s Name :” get fname
@10,4 say “3. Address :” get add
@11,31 say “NANDIKOTKUR” colo +gr/w
@12,31 say “KURNOOL DIST” colo +r/w
@13,4 say “4. Date of Birth :” get dob
@14,4 say “5. Education :”
@15,7 say “Qualification :” get qua
@16,4 say “6. Course Name :” get cou
@19,4 say “7. Date of Joining :” get date
@19,31 say “Signature of the Student”
@20,4 say “8. Place :” get pla
63
S. MADHU MOHAN FOXPRO
@21,31 say “Signature of the Director”
@22,40 say “with seal”
^w
REPORT
Report displays or prints reports under the control of a report definition file
created with “modify report” or “create report”.
The default extension for a report definition file is “.FRX”
How to Create Report :
First Method :
Create Report file name
Create Report Mohan.frx
To run report from command window.
Run Report <file name>
Run Report mohan.frx
Run Report mohan preview
Second Method :
♥ Ðèþ$$…§æþ$V> FoxPro ¯èþ…§æþ$ JMæü .dbf òœOÌŒý¯èþ$
™èþÄæý*Ææÿ$ ^óþÄæý$ÐèþËÄæý$$¯èþ$.
♥ ™èþÆ>Ó™èþ command window ¯èþ…§æþ$ "create report
<filename>" (dbf file name).
Ex : CREATE REPORT MADHU
♥ madhu.frx A¯óþ window ÐèþçÜ$¢…¨.
♥ C糚yæþ$ Pg HeaderÌZ Title CÐéÓÍ. (SMS Computers)
♥ Details ÌZ cursor¯èþ$ MìüÏMŠü ^óþíÜ Report Menu ÌZ Filed option
¯èþ$ MìüÏMŠü ^óþÄæý*Í.
♥ Expr...... ° MìüÏMŠü ^óþíÜ Field Names ¯èþ$ double click ^óþÄæý*Í.
♥ ò³OÑ«§æþ…V> JMöPMæüP Field ¯èþ$ òÜÌñýMŠüt ^óþÄæý*Í.
♥ C糚yæþ$ Pg Footer ÌZ MìüÏMŠü ^óþíÜ Report Menu ÌZ Field Select
^óþíÜ Expr.... ¯èþ$ double click ^óþÄæý*Í.
64
S. MADHU MOHAN FOXPRO
♥ Report Expression window ÌZ Calculate ò³O MìüÏMŠü ^óþíÜ
Ðèþ$¯èþMæü$ M>ÐèþËíܯèþ Bç³Û¯Œþ¯èþ$ òÜÌñýMŠüt
^óþíÜ OK A¯éÍ. Ðèþ$äå OK A¯éÍ.
♥ Ctrl + W (Save) ^óþÄæý*Í.
♥ Report Form Madhu to Madhu.txt
♥ !Edit madhu.txt
ò³O Ñ«§æþ…V> Report ¯èþ$ ™èþÄæý*Ææÿ$^óþÄæý*Í.
To Modify a Report :
Modify Report <report name>
Modify Report mohan.frx
Last : Report format mohan preview.
LABEL
Label displays or prints labels under the control of a label definition file created
with “modify label” or “create label”.
The default extension for a label definition file is “.LBX”
First Method :
1. Create data base file.
Ex : create mohan.dbf
2. create label file
Ex : create label mohan.lbx
3. Ctrl+E
4. Ctrl+W
5. Ctrl+w (save)
6. Run menu, select label.
Second Method :
♥ Ðèþ$$…§æþ$V> FoxPro ¯èþ…§æþ$ JMæü .dbf òœOÌŒý¯èþ$
™èþÄæý*Ææÿ$ ^óþÄæý$ÐèþËÄæý$$¯èþ$.
♥ ™èþÆ>Ó™èþ command window ¯èþ…§æþ$ "create label
<filename>" (dbf file name).
Ex : CREATE LABEL MADHU
♥ madhu.lbx A¯óþ window ÐèþçÜ$¢…¨.
65
S. MADHU MOHAN FOXPRO
♥ C糚yæþ$ label menu Expression ¯èþ$ MìüÏMŠü ^óþíÜ Field Names
¯èþ$ double click ^óþÄæý*Í.
♥ ò³OÑ«§æþ…V> JMöPMæüP Field ¯èþ$ òÜÌñýMŠüt ^óþÄæý*Í.
♥ Ctrl + W (Save) ^óþÄæý*Í.
♥ Label Form Madhu to Madhu.txt
♥ !Edit madhu.txt
ò³O Ñ«§æþ…V> Label ¯èþ$ ™èþÄæý*Ææÿ$^óþÄæý*Í.
℘℘℘
S. MADHU MOHAN
M.A., PGDSE & DHE.
66

More Related Content

What's hot

Linux lab manual by zoom
Linux lab manual by zoomLinux lab manual by zoom
Linux lab manual by zoomSatya Johnny
 
Training MS Access 2007
Training MS Access 2007Training MS Access 2007
Training MS Access 2007crespoje
 
Fluent Ribbon Control Suite Walkthrough
Fluent Ribbon Control Suite WalkthroughFluent Ribbon Control Suite Walkthrough
Fluent Ribbon Control Suite WalkthroughDaniel Degtyarev
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationArun Sharma
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functionsfarwa waqar
 
Normalization in a Database
Normalization in a DatabaseNormalization in a Database
Normalization in a DatabaseBishrul Haq
 
Fundamentals of Database system
Fundamentals of Database systemFundamentals of Database system
Fundamentals of Database systemphilipsinter
 
MS Access and Database Fundamentals
MS Access and Database FundamentalsMS Access and Database Fundamentals
MS Access and Database FundamentalsAnanda Gupta
 
Control panel by
Control panel byControl panel by
Control panel byNoor Fatima
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFBiplap Bhattarai
 
Improving decision making and managing knowledge
Improving decision making and managing knowledgeImproving decision making and managing knowledge
Improving decision making and managing knowledgeProf. Othman Alsalloum
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFOum Saokosal
 
Cloud-Based Big Data Analytics
Cloud-Based Big Data AnalyticsCloud-Based Big Data Analytics
Cloud-Based Big Data AnalyticsSateeshreddy N
 
2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data Structure2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data StructureTish997
 

What's hot (20)

Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Linux lab manual by zoom
Linux lab manual by zoomLinux lab manual by zoom
Linux lab manual by zoom
 
Training MS Access 2007
Training MS Access 2007Training MS Access 2007
Training MS Access 2007
 
Fluent Ribbon Control Suite Walkthrough
Fluent Ribbon Control Suite WalkthroughFluent Ribbon Control Suite Walkthrough
Fluent Ribbon Control Suite Walkthrough
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
The f1 to f12 keys
The f1 to f12 keysThe f1 to f12 keys
The f1 to f12 keys
 
SQL
SQLSQL
SQL
 
Normalization in a Database
Normalization in a DatabaseNormalization in a Database
Normalization in a Database
 
Fundamentals of Database system
Fundamentals of Database systemFundamentals of Database system
Fundamentals of Database system
 
Database Chapter 3
Database Chapter 3Database Chapter 3
Database Chapter 3
 
MS Access and Database Fundamentals
MS Access and Database FundamentalsMS Access and Database Fundamentals
MS Access and Database Fundamentals
 
Control panel by
Control panel byControl panel by
Control panel by
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 
Improving decision making and managing knowledge
Improving decision making and managing knowledgeImproving decision making and managing knowledge
Improving decision making and managing knowledge
 
Queries
QueriesQueries
Queries
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Cloud-Based Big Data Analytics
Cloud-Based Big Data AnalyticsCloud-Based Big Data Analytics
Cloud-Based Big Data Analytics
 
2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data Structure2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data Structure
 

Similar to 005 foxpro

PC Software - Computer Application - Office Automation Tools
PC Software  -  Computer Application - Office Automation ToolsPC Software  -  Computer Application - Office Automation Tools
PC Software - Computer Application - Office Automation Toolszatax
 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptPDhivyabharathi2
 
What is DOS (Disk Operating System).pdf
What is DOS (Disk Operating System).pdfWhat is DOS (Disk Operating System).pdf
What is DOS (Disk Operating System).pdfRohitRoshanBengROHIT
 
File Commands - R.D.Sivakumar
File Commands - R.D.SivakumarFile Commands - R.D.Sivakumar
File Commands - R.D.SivakumarSivakumar R D .
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxAssadLeo1
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsShankar Mahure
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdfMarsMox
 
Applecmdlista zs
Applecmdlista zsApplecmdlista zs
Applecmdlista zsBen Pope
 
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptxLab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptxCiceer Ghimirey
 
Dos commad. by ammar nawab ppt
Dos commad. by ammar nawab pptDos commad. by ammar nawab ppt
Dos commad. by ammar nawab pptAmmar_n
 

Similar to 005 foxpro (20)

Comp practical
Comp practicalComp practical
Comp practical
 
PC Software - Computer Application - Office Automation Tools
PC Software  -  Computer Application - Office Automation ToolsPC Software  -  Computer Application - Office Automation Tools
PC Software - Computer Application - Office Automation Tools
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
Unix3
Unix3Unix3
Unix3
 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
 
Introduction to linux day1
Introduction to linux day1Introduction to linux day1
Introduction to linux day1
 
What is DOS (Disk Operating System).pdf
What is DOS (Disk Operating System).pdfWhat is DOS (Disk Operating System).pdf
What is DOS (Disk Operating System).pdf
 
File Commands - R.D.Sivakumar
File Commands - R.D.SivakumarFile Commands - R.D.Sivakumar
File Commands - R.D.Sivakumar
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptx
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdf
 
Applecmdlista zs
Applecmdlista zsApplecmdlista zs
Applecmdlista zs
 
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptxLab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
 
Module 5 file cp
Module 5 file cpModule 5 file cp
Module 5 file cp
 
Linux commands
Linux commandsLinux commands
Linux commands
 
File management
File managementFile management
File management
 
Dos commad. by ammar nawab ppt
Dos commad. by ammar nawab pptDos commad. by ammar nawab ppt
Dos commad. by ammar nawab ppt
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 

Recently uploaded

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

005 foxpro

  • 1. S. MADHU MOHAN FOXPRO FOXPRO The old version FoxPro is “FoxPro2.0” (Dos based). Latest version of FoxPro is “FoxPro 2.6” and “Visual FoxPro” . FoxPro 2.6 is a Dos based FoxPro. This is a CUI (Character User Interface) user. Visual FoxPro is a Window based FoxPro. This is a GUI (Graphical User Interface) user. FoxPro is a DBMS package. DBMS : Data Base Management System. Example : FoxPro, dbase, Clipper etc. RDBMS : Relational Data Base Management System. Example : Oracle, Sybase etc. ORDBMS : Object Relational Data Base Management System. Example : C++ ,VC++ etc. Data means : Some information (or) An unprocessed information Regarding any object. Means : Fields – Columns Records – Rows Tables – File DBF – Data Base file. Note : All FoxPro commands are used full (or) 4 characters. COMMANDS : CREATE : To create a database file. Syntax : create <file name> Example : create madhu LIST : Display the contents of dbf files. (or) Display all records, (or) Lists all the records of the currently active dbf along with record no’s. Syntax : list (or ) F3 1. list name, no Example : list name, no 2
  • 2. S. MADHU MOHAN FOXPRO 2. To display name,no,total, fileds where no=2 Example : list name,no,total for no=2 3. display records whose no>2 Example : list for no>2 4. display records whose no<2 Example : list for no<2 5. displaying records no>2 Example : list for recno()>2 6. List off : Suppress(hides) records no column. List for name= “mohan” List while course List while course= “PGDSE” List name,no for course= “PGDSE” to print List for deleted() APPEND : To add the records to the existing DBF. Syntax : Append USE : To open particular data base file. Syntax : Use <file name> Use mohan QUIT : Exit from the FoxPro. Syntax : Quit BROWSE : (Ctrl +N ) Browse opens various options it allows editing several records in the full screen window. To insert a new record to the bdf in browse option. Syntax : browse DELETE : Deletes particular record or range of record. 1. To delete 5th record. Goto 5 Delete 3
  • 3. S. MADHU MOHAN FOXPRO 2. To delete records>10 Goto 10 Delete rest Delete for recno()>10 3. To delete records>10 and <=15 (11,12,13,14,15) Delete for recno()>10 and recno<=15 4. To delete records permanently from the dbf. Delete recno()=5 and recno<=10 Pack 5. Delete for upper (name)= upper (smm) Delete for no>10 RECALL : To recall the deleted records. Which are delete d by delete command. To recall 3rd record Goto 3 recall all Recall recall next 5 MODI STRUCTURE : We can make modifications in the existing dbf structure., like modifying width of column, modifying name of the column, adding new column (ctrl + I ) and deleting column. Syntax : modi stru EDIT : Edit used for making modifications in a particular record modifications in 100 records. Example : Goto 100 Goto top(1 record) Goto bottom (100 record) Edit Edit Edit REPLACE : This command replaces the existing column or field with a new value or text. Syntax : replace <condition> Example : 1. Finding total. Replace all total with m1+m2 2. Finding average. Replace all average with total/2 Replace all average with m1+m2/2 4
  • 4. S. MADHU MOHAN FOXPRO 3. Assign 1000 Rs. Bonus for all employees. Replace all Bonus with 1000 Replace all Bonus with Basic*10/100 4. Assign depart name for department colum. Replace all Dept with “Finance” 5. To convert name into upper case. Replace all name with Upper(name) 6. To convert name into lower case. Replace all name with lower(name) 7. To convert name into proper case. Replace all name with proper(name) 8. Replace name Hari Shankar where roll no=4. Replace name with “Hari Shankar” for no=4 9. Replace name with lower (name) for function>=number Upper another DISPLAY : Displays the current record of the active data base file. Syntax : Display 1. Display Files : Lists files on the current directory. 2. Display History : Lists the command in the History mode in the order of entry. 3. Display Memory : Displays the Name, type and size of the active memory variables. 4. Display Status : Displays information about open files and system parameters. 5. Display Structure : Displays the structure of the file in use. (or) Displays the structure of existing data base file. APPEND : This command allow user to expend the data file by giving new records. Syntax : Append Examples : 1. Append : adds records at the end of file. 2. Append Blank : Adds one blank record at the end of a file. 3. Append From file name : Adds records of new file name. dbf. ERASE : Removes a file from the directory permanently. Syntax : Erase <file name. Example : Erase madhu.dbf Erase mohan.prg 5
  • 5. S. MADHU MOHAN FOXPRO Note : This command is not applicable for the files which are currently active in the memory. PACK : Removes records permanently from the dbf file. CLOSE : Close, closes the type of the specified and makes the buffers empty and ensures that the closed files are upto date. Syntax : Close CLOSE ALL : Specifies all the active files which are opened to be closed. (or) close all data base file. Syntax : Close all ZAP : Removes all the records irrespective of having been marked or not marked for deletion. Syntax : Zap FUNCTION KEYS : KEY WORKING COMMAND F1 Help F2 Assist F3 List F4 Dir F5 Display Structure F6 Display Status F7 Display Memory F8 Display F9 Append F10 Edit DELETED( ) : Returns .T. if the current record is marked for deletion, otherwise .F. Example : 1. Use madhu.dbf .T. = True Goto 2 .F. = False ?Deleted( ) ? = Print symbol. Delete ?Deleted( ) 6
  • 6. S. MADHU MOHAN FOXPRO 2. Delete for no>2 List for Deleted( ) List for records which are marked for deletion. LOCATE : Locate finds the first record in a dbf that matches a search criterion (condition) specified in the for or while portion of the command. If locate fails to find a matching record, the EOF( ) function is set to .T. and the Found( ) function set to .F. Syntax : Locate Scope [for <condition>] [while<condition>] Example : Locate for name= “madhu” Delete Locate for no5= “S” Delete GOTO : Positions the record pointer at the specified record position. Syntax : Goto Recno [top][bottom] Example : Goto 10 Goto Top Goto Bottom Display Display Display SKIP : Skip to the next record in a database. Can also skip more or less than one record when the following command is used. Syntax : skip[n] [n=number] Moves the record pointer to a specified no of records from the current record position. “N” is a number which can be either positive or negative. If “N” is a positive number, then the record pointer moves in the forward direction. Otherwise moves in the backward direction. If no value is given +1 is default. Example : 1. Skip - Skips to next record. 2. Skip 4 - Moves to 4th record forwards. 3. Skip -3 - Moves to 3rd record backwards. COPY : 1. Makes a copy of an existing file in disk. Example : copy to new file. 2. copy structure : copy structure to new file. Copies only structure of current dbf into a new file. 7
  • 7. S. MADHU MOHAN FOXPRO 3. copy to new file for name= “mohan” Syntax : copy to new file for name= “name” Copies all the records having the name “mohan” into new file. 4. copy file madhu.prg to mohan.prg Copies madhu.prg into mohan.prg on the same list. OPERATORS An operator is a symbol (or) a set of characters which perform a pre-defiend operation. 1. ARITHMETIC OPERATORS : These operators which perform an arithmetic operation. Usage of these operators is limited to numeric data type. But the operators plus(+), minus(-) can be used on date data type also. The various arithmetic operators are., Symbol Uses + (plus) Addition 10+20=30 Any Date +1 Display Next day 31-05-2007 +1 01-06-2007 – (minus) Subtraction 20-10=10 Any Date -1 Display Yester day 02-06-2007 -1 01-06-2007 * (asterisk) Multiplication 10*5=50 / (slash) Division 10/5=2 ^ or ** (copy symbol) Exponentiation 2**3=8 (2*2*2) 2^3=8 (2*2*2) ( ) (brackets) Grouping [(15*10)+(20*5) 50+100=150] 2. RELATIONAL OPERATORS : These operators are used to compare two same type of values. The result of search a comparison will be either of the two : .T. or .F. These operators can be used on numeric, character and date data type. Symbol Uses = (equal) Equality (300=300) = .T. RAMA= rama = .F. > (greater than) Greater than (500>600) = .T. (500>300) = .F. Bruce=amar=.F. < (less than) Less than (200<100) = .T. (100<200) = .F. 8
  • 8. S. MADHU MOHAN FOXPRO Symbol Uses >= Greater than equal to <= Less than equal to <> or # (not equal) 5<>5 = .F. 5#5 = .F. 5<>6 = .T. 5#6 = .T. $ (dollar sign) (Useful for character type. Character 1 $ character 2 returns .T. If character1 in character 2) Vijaya $ Vijayawada = .T. Vijayawada $ Vijaya = .F. 3. LOGICAL OPEATORS : These operators compare two or more expressions of numeric, character and date data type and either .T. (or) .F. result. Symbol Uses .AND. states that both expressions compared are true (.T.) .OR. states that either of the two expressions is .T. .NOT. states that the expression is not true .T. FILES IN FOXPRO AND THEIR EXTENSIONS : Extension File Description .DBF Data base file. .DBT Data base text file. .FMT Format file. .FRM Formatted report file. .LBL Label file. .MEM Memory file. .NDX Data base Index file. .PRG program file. .QRY Query file. .SCR Screen setting file. .VUE View file. .CAT Catalo file. 9
  • 9. S. MADHU MOHAN FOXPRO RETURN DOS : QUIT : Closes the open file, active updated data base file and quits FoxPro and returns to the Dos prompt permanently. If you need FoxPro once again you have to load again by entering the command FoxPro. ! (or) RUN : Invokes the operating system temporarily and executes a valid internal or external dos commands and returns to FoxPro immediately. The current disk must contain the file command. Syntax : ! <dos command> or run <dos command> Example : ! dir run dir SORT : Re-arranges records on a data base file into sorted order. It require that records be sorted to another data base file. Syntax : Sort <scope> to <filename>on <field>[/a][/d][/c] scope [,<additional fields>[(/a)(/d)(/c)] {next, rest, [while <condition>][for<condition>] all} Note : <scope> scope is FoxPro scope option. <file name> File name is the name of FoxPro. <field> Field is the name of the feel on which the data base records or to be sorted. /a indicates ascending order. /d indicates descending order. /c indicates that upper case & lower case difference are to be ignored. While sorting on a character field. If this is ignored, the sort takes place in the order of ASCII values. ADDITIONAL FIELDS : They are the field names to be taken as secondary fields when the primary field value is repeated in the data base. For and while specifies the condition, so that only the records matching the given condition will be copied on to the new file. Up to 10 fields can be included in the sort. Fields should be listed from left to right in order of importance. Example : Sort on sname, maths, science to sroted file. Sort on name/ac to new file. “/a” {ascending, upper/lower cases) 10
  • 10. S. MADHU MOHAN FOXPRO INDEX : Index command includes up to seven index files, that have been created previously with the “index on” command. {dir *.idx – to see index files) Syntax : Index on field to <file name> Example : Index on sno to no FIND : Find quickly finds a value in an index file and sets the record pointer into that record. Syntax : Find <constant> If find is successful, then “found ( )” function returns .T. , otherwise “found ( )” function returns .F.. Example : Find 100 Find mohan SEEK ( ) : Seek looks up the contents of a memory variable in an index file. Its supports both memory variables and expressions. If seek is successful, the “found ( )” function is set to true. Syntax : Seek <expression> Example : Seek 100 Seek 100 Seek mohan Seek N, Name= “mohan” Seek upper(name) TYPE : Displays the contents of a disk file and also prints the contents of a file. Syntax : Type <file name> [print] Example : Type mohan, type mohan.prg to print RENAME : Changes the name of a given old file with a new file. It does not effect the contents of the file. Syntax : Rename <old file name> to <new file name> Example : Rename madhu.prg to mohan.prg DATA TYPES: Data Type Maximum Width Default Character 254 10 Numeric 20 8 11
  • 11. S. MADHU MOHAN FOXPRO Date 8 8 Logical (T/F) (Y/N) 1 1 Memo Ctrl+PgDown(whole window) 10 Float 8 Picture General SET COMMANDS : The “Set” commands when used alone, display all current parameter setting and allow them to be changed through a menu. “Set” displays a full screen menu – driven technique for viewing and changing current parameter settings. 1. SET ALTERNATE [ON][OFF] : Determines where ensuring screen text is sorted on the currently active alternate file. 2. SET ALTERNATE TO [FILE NAME] : Creates an ASCII text file to which FoxPro can direct output. The command without any file name closes the currently active alternate file. 3. SET BELL [ON][OFF] : Determines whether the warning bell sounds when you type beyond the width of a field or enter invalid data type. 4. SET CENTURY [ON][OFF] : Allows the input and display of century prefixes on the year portion of dates. 5. SET DECIMAL TO [WIDTH] : Determines the minimum number of decimal places displayed in the results of numeric expressions. 6. SET DATE <DATE FORMAT> : “<Format>” is any valid FoxPro date format, which can be any of the following. American MM/DD/YY German DD.MM.YY British DD/MM/YY French DD.MM.YY 12
  • 12. S. MADHU MOHAN FOXPRO 7. SET ECHO [ON][OFF] : Displays command lines from FoxPro program on the screen or the printer while running the programmes. 8. SET FUNCTION <KEY> TO <STRING> [;] : Allows each function key to be reprogrammed to represent character expression up to 30 characters long “<key>” is the number of the function key to be program “<string>” is the character expression which you would like to generate by pressing that function key. “[i]” includes an auto carriage return to that string. Example : Set Function F11 to “clear” Set Function F12 to “create”. Assigns the command clear to F3 and also includes a return. 9. SET HISTORY [ON][OFF] : Determines whether commands are stored in the History file or not. 10.SET MARGIN TO <NUMBER> : Specifies the left margin for the printer outputs. 11.SET PRINT [ON][OFF] : Directs all output that is not formatted with the at [@] …. Say commands to the printer and the screen. 12.SET TALK [ON][OFF] : Determines whether certain commands display informative message. 13.SET STATUS [ON][OFF] : Determines whether the status bar is displayed at the bottom of the screen. 14.SET COLO [ON][OFF] : Displays the colors from FoxPro program on the screen or the printer while running the programs. 15.SET CLOCK [ON][OFF] : Displays or sets the clock from FoxPro program on the screen. 16.SET SAFE [ON][OFF] : Determines whether the FoxPro program running the computer the computer should be safe. 13
  • 13. S. MADHU MOHAN FOXPRO Ctrl + F7 : This command is used for moving command window one location (place) to another location by using arrow keys. Ctrl + F8 : This command is used for we can increase or decrease the command window by using arrow keys. Ctrl + F7 : This command is used for to hide or unhide showing the command window. Ctrl + W : This command is used for to save the FoxPro program. PROGRAMS 1. Write a program to display name, no, course. Solution : MODI COMM MADHU.PRG Set talk off Clear Accept “Enter Your Name :” to name Input “Enter Your Number :” to no Accept “Enter Course Name :” to course Clear ? “Name :”, name ? “Number :”, no ? “Course :”, course ^w Output Do Madhu 2. Write a program to calculate the addition. Solution : MODI COMM ADDITION.PRG Set talk off Clear A=100 B=200 C=A+B ? “Sum :”,C ^w Output Do Addition Sum = 400 14
  • 14. S. MADHU MOHAN FOXPRO 3. Write a program to accept student name, no, marks in 3 subjects. Find total and average marks and display them. Solution : MODI COMM STUDENT.PRG Set talk off Clear Accept “Enter Student Name :” to sname Input “Enter Student Number :” to sno Input “Enter Marks in Oracle :” to m1 Input “Enter Marks in HTML :” tp m2 Input “Enter Marks in SAP :” to m3 Total=m1+m2+m3 Average=total/3 Clear ? “Student Name :”, sname Output ? “Student Number :”, sno Do Student ? “Oracle Marks :”, m1 ? “HTML Marks :”, m2 ? “SAP Marks :”, m3 ? “Total Marks :”, total ? “Average Marks :”, average ^w 4. Write a program to accept employee name, no, basic, hra, da, ta, pf. Find gross salary and net salary. Solution : MODI COMM EMPLOYEE.PRG Set talk off Clear Accept “Enter Employee Name :” to name Accept “Enter Employee Number :” to no Input “Enter Basic Salary :” to basic Input “Enter HRA :” to hra Input “Enter DA :” to da Input “Enter TA :” to ta Input “Enter PF :” to pf Gross salary = basic+hra+da+ta Net salary = gross salary – pf Clear ? “Employee Name :”, name ? “Employee Number :”, no ? “Basic Salary :”, basic ? “HRA :”, hra ? “DA :”, da ? “TA :”, ta ? “PF :”, pf ? “Gross salary :”, gross salary ? “Net salary :”, net salary ^w 15
  • 15. S. MADHU MOHAN FOXPRO CONTROL STATEMENTS : 1. If ……. Endif 2. If ……. Else ………. Endif 3. Docase …….. Endcase If …. End if : If statement checks the given condition. If the condition is satisfied, then executes the statements which are mentioned between “if” and “endif” . Syntax : If <condition> Statement Endif 5. Write a program for demonstrating “if” condition. Solution : MODI COMM IF.PRG Set talk off Clear Input “Enter Any Number :” to no If (n>0) ? “This is a Positive Number :”, no Endif ^w If …. Else …. Endif : If statement executes the statements when the condition is satisfied, else executes the other statement which are presents after the else statement. Syntax : If <condition> Statements Else Statements Endif MOD ( ) : This function is used to find the remainder from given expression. Syntax : MOD (dividend, division) Example : ?MOD (100,2) ? MOD (9,2) Output : “0” “1” 6. Write a program to accept a number. Find whether the given number is even or odd number. Solution : MODI COMM EVEN.PRG Set talk off Clear 16
  • 16. S. MADHU MOHAN FOXPRO Input “Enter Any Number :” to no R=MOD(no,2) Output If (R=0) Any Number : 20 ? “Even Number” Even Number Else ? “Odd Number” Any Number : 25 Endif Odd Number ^w 7. Write a program to accept a year. Find leap year or not. Solution : MODI COMM YEAR.PRG Set talk off Clear Input “Enter Any Year :” to year Output R=Mod(year,4) Any Year : 2004 If(R=0) Leap Year ? “Leap Year” Else Any Year : 2007 ? “Not Leap Year” Not Leap Year Endif ^w Docase ….. Endcase : Docase statements executes one statement or case among number of cases,, which case is satisfied they are given criteria. End case is the terminator of docase. @ say (row, column) : This statement prints the message at the required place or location on the monitor Get : This command accepts some value or text into the variables. This get statement must followed along with “@Say” command. The screen divides 80 columns, 24 rows in FoxPro, or inserting the monitor. Syntax : @row, column say “message” get <variable name> STORE : Store command used for declaring variables and storing some value into the variables. Store 0 to no, numeric values or variables. Store 0 to no, basic, hra, da, ta, pf To declare numeric variables and storing “0” in the above variables. To declare character variables and allocating 20 spaces for the name variable. 17
  • 17. S. MADHU MOHAN FOXPRO READ : So “Read” command stops the cursor after printing the message using “@say command” also stores information into the variables. 8. Write a program to accept SMM Computers. Find even number, leap year, negative number. Solution : MODI COMM MADHU.PRG Set talk off Clear Store 0 to no, R, year, G @2,25 say “SMM COMPUTERS” @4,15 say “1. Even or Odd” @5,15 say “2. Leap year or Not” @6,15 say “3. Positive or Negative” @7,15 say “4. Exit” @8,15 say “------------------------------“ @10,20 say “Enter Your Choice :” get no Read Docase Case no =1 Input “Enter Any Numebr :” to R R=Mod(no,2) If (R=0) ? “Even Number” Else ? “Odd Number” Endif Case no =2 Input “Enter Year :” to year R=Mod(year,4) If (R=0) ? “Leap Year” Else ? “Not Leap Year” Endif Case no =3 Input “Enter any Number :” to G If(g>0) ? “Positive Number” Else ? “Negative Number” Endif Case no =4 ? “Thank You very much” ? “S. MADHU MOHAN” Endcase ^w Output : Do madhu 18
  • 18. S. MADHU MOHAN FOXPRO 9. Write a program to accept customer name, product no, product name, quantity, rate. Find the bill amount. If the amount is greater than 500 (>500)then discount is 10% (=10%) of the bill amount, if bill amount less than 500 (<500), display message “Sorry! No Discount”. Solution : MODI COMM CUSTOMER.PRG Set talk off Clear Store space(20) to cname, pname Store 0 to pno, prate, quantity, bill, discount, net bill @6,15 say “Enter Customer Name :” get cname @7,15 say “Enter Product Name :” get pname @8,15 say “Enter Product Number :” get pno @9,15 say “Enter Product Quantity :” get quantity @10,15 ssay “Enter Product Rate :” get prate Read Bill=quantity*prate @12,15 say “Total Bill Amount :” get Bill If (bill>500) Discount=bill*10/100 or Discount=bill*0.1 Else Wait Window “Sorry! No Discoun” Endif Net bill=bill-discount @13,15 say “Net Bill Amount :” get net bill Wait Window “Thank You” time out 1 ^w WAIT WINDOW : This command prints the message which is specified between the quotations after this wait window until user press “Esc key” or Else we can specify time along with this window. Syntax : Wait window “some message” time out <minutes> Example : Wiat window “S. MADHU MOHAN” Time out 1 COLORS : Black – N Green – G Inverse – I Red – R Blank – X Brown – Gr Magnenta – Rb White – W Blue – B Cyan – Bg/Gb Yellow – Gr+ Underlined – U Colors Background settings : W+/B W+/BG GR+/B R+/B W+/GR W+/N W/N U+/N GR+/RB N+/N GR+/B ++G/B 19
  • 19. S. MADHU MOHAN FOXPRO 10. Write a program to set the color for name madhu mohan. Solution : MODI COMM COLOR.PRG Set talk off Clear Set colo to R++ or R* ? “S. MADHU MOHAN” Set colo to ^w 11. Write a program to accept student name, no, marks in 2 subjects. Find total, average. If avg>=35 and <50 result =third class, avg>=50 and <60 result=second, avg>=60 and <75 result= first, avg>=75 result= distinction. Solution : MODI COMM STUDENT.PRG Set talk off Clear Store space(20) sname, result Store 0 to sno,m1,m2, tot, avg @6,15 say “Enter Student Name :” get sname @7,15 say “Enter Student Number :” get sno @8,15 say “Enter Marks in FoxPro :” get m1 @9,15 say “Enter Marks in Internet :” get m2 Read Tot=m1=m2 Avg=tot/2 @11,15 say “Total Marks :” get tot @12,15 say “Average Marks :” get avg If (avg>=35 .and. avg<50) Result= “Third Class” Else If(avg>=50 .and. avg<60) Result= “Second Class” Else If(avg>=60 .and. avg<75) Result= “First Class” Else If (avg>=75) Result= “Distinction” Else Result= “Fail” Endif Endif Endif Endif @15,15 say “Result is :” get result ^w 20
  • 20. S. MADHU MOHAN FOXPRO CASE STRUCTURE or LOOPING STRUCTURE : 1. Do while …… Enddo 2. For ……. Endfor Do While …... Enddo : “Do while” loop executes the statements until the given condition is satisfied. If the condition becomes falls it comes out from the loop that is do while loop. “Enddo” is the terminator of the “Do while” loop. Syntax : Do while <condition> Statements Enddo 12. Write a program to print 20 numbers. Solution : MODI COMM NUMBERS.PRG Set talk off Clear A=1 Do while(a<=20) ?A A=A+1 Enddo ^w 13. Write a program to Hello! Mohan message 10 times. Solution : MODI COMM HELLO.PRG Set talk off Clear A=1 Do while(A<=10) ? “Hello! Mohan”, A A=A+1 Enddo ^w 14. Write a program to print 20 numbers with reverse order (20 to 1). Solution : MODI COMM REVERSE.PRG Set talk off Clear A=20 Do while(A>=1) ?A A=A-1 Enddo ^w 21
  • 21. S. MADHU MOHAN FOXPRO 15. Write a program to print multiplication table for a given number. Solution : MODI COMM MULTIPLICATION.PRG Set talk off Clear Store 0 to A,B,C Input “Enter any number :” to A Do while(B<=10) C=A*B ? A, “X”, B, “=”,C B=B+1 Enddo ^w 16. Write a program to print 20 multiplication tables. Solution : MODI COMM MULTIPLICATION.PRG Set talk off Clear A=1 Do while (A<=20) B=1 Do while (B<=10) ? R, “X”, A, “=”, B*A A=A+1 Enddo R=R+1 Wait “Continue” Clear Enddo ^w For ….. Endfor : “For” loop executes the commands until the condition becomes true. If the condition becomes false it comes out from the “for loop”. “End for” is the terminator of the “For” loop. Syntax : For variable name= Initial value to Last value (step value) Statements Next of skip value Endfor 17. Write a program to 20 numbers. Solution : MODI COMM NUMBER.PRG Set talk off Clear A=1 For A=1 to 20 Endfor ?A ^w 22
  • 22. S. MADHU MOHAN FOXPRO 18. Write a program to print 20 numbers with reverse order (20 to 1). Solution : MODI COMM REVERSE.PRG Set talk off Clear A=20 For A=20 to 1 step -1 ?A Endfor ^w 19. Write a program to print multiplication table for a given number. Solution : MODI COMM MULTIPLICATION.PRG Set talk off Clear Store 0 to sno, A Input “Enter any number :” to sno For A=1 to 10 ? sno, “X”, A, “=”, sno*A Endfor ^w 20. Write a program to print 20 multiplication tables. Solution : MODI COMM MULTIPLICATION.PRG Set talk off Clear For A=1 to 20 For B=1 to 10 ? A, “X”, B, “=”, A*B Endfor Wait Endfor ^w 21. Write a program to accept student name, no, marks in 2 subjects. Find total, average. If avg>=35 and <50 result =third class, avg>=50 and <60 result=second, avg>=60 and <75 result= first, avg>=75 result= distinction. If marks <35 result=fail. Solution : MODI COMM RESULT.PRG Set talk off Clear Store space (20) to sname, result Store 0 to sno, m1, m2, m3, tot, avg @6,15 say “Enter Student Name :” get sname @8,15 say “Enter Student Number :” get sno @10,15 say “Enter Marks in C :” get m1 @12,15 say “Enter Marks in C++ :” get m2 23
  • 23. S. MADHU MOHAN FOXPRO @14,15 say “Enter Marks in VC++ :” get m3 Read Tot=m1+m2+m3 Avg=tot/3 @16,15 say “Total Makrs :” get tot @18,15 say “Average Marks :” get avg If (m1>75 .and. m2>75 .and. m3>75) ? “Pass, Distinction” or Result= “Distinction” Else If (m1>605 .and. m2>60 .and. m3>60) ? “Pass, Fist Class” or Result= “First Class” Else If (m1>50 .and. m2>50 .and. m3>50) ? “Pass, Second Class” or Result= “Second Class” Else If (m1>35 .and. m2>35 .and. m3>35) ? “Pass, Third Class” or Result= “Third Class” Else ? “Fail” or Result= “Fail” Endif Endif Endif Endif ^w Functions A function is a predefined program. Which performs a particular task or work. DATE Functions : DATE ( ) : Returns the system date. Syntax : Date () Example : ?Date() DAY ( ) : Returns the numeric value of the day of the month from a date. Syntax : Day(<date>) Example : ?Day(Date()) MONTH ( ) : Returns the number of the month in the date expression. Syntax : Month (<date>) Example : ?Month(Date()) YEAR ( ) : Returns the numeric value of the year from a date expression. Syntax : Year (<date>) Example : ?Year(Date()) 24
  • 24. S. MADHU MOHAN FOXPRO CToD ( ) : Converts a character variable in date format to the date data type. Syntax : CToD(“date”) (CToD= Character to date) Example : CToD(“06/01/2007”) output : 06/01/2007 DToC ( ) : Date to character, converts any date to a character string. Syntax : DToC(<date>) (DToC= Date to Character) Example : DToC(Date()) CMONTH ( ) : Current month or character month. Returns character month name of a given date. Syntax : Cmonth(<date>) Example : Cmonth(Date()) CDOW ( ) : Character day of week. Syntax : CDOW(<date>) Example : CDOW(Date()) output : Thursday LUPDATE ( ) : Returns the date, as the date data type of the last “update” of the currently selected data base file. Syntax : Lupdate() Example : ?Lupdate() TIME ( ) : Returns the system time as the character string. Syntax : Time() Example: ?Time() output : 9:40:00 NUMERIC Functions : COUNT( ) : Counts how many records in data base, meet a search condition. The command count alone counts how many records are there in the data base file. For and While specify the condition for which the FoxPro searches and counts the number of records matching the given condition. [To <Memory variable>] specify the name of the memory variable in which the data has to be stored. Syntax: Count [For<condition>][While<condition>][To memory variable] Example: Count() Count to N Count for course= “PGDSE” to PGTOTAL ? PGTOTAL 25
  • 25. S. MADHU MOHAN FOXPRO SUM ( ) : The command sum alone returns the sum of numeric fields. Syntax : Sum[<expre>][scope][For<expre>][While<expre>][To <memory variable>] <expression> expressions are numeric field names or expressions of numeric fields. <scope> scope is the (FoxPro) data base scope option. Example : Sum() Sum total to tot, ?tot Sum total, for total>=200 to ABC ?ABC AVERAGE( ) : This command calculates the average of numeric fields. Syntax : Average[<expre>][scope][For<expre>][While<expre>][To <memory variable>] Examples : Average () Average total to tot ?tot Average total for total>=200 to XYZ ?XYZ INT ( ) : (Integer – decimal) Integer function, converts any numeric expression into integer by truncating (cut) the decimal places. Syntax : Int (<number>) Example : Int (56.3482) output : 56 MOD( ) : Returns the remainder of the division of numbers specified in the argument i.e., modules. Syntax : Mod(<no1><no2>) ?Mod(10,30) output : 1 (remainder) ABS ( ) : (Absolute) Returns the absolute value of a numeric expressions. Syntax : Abs(<number>) Example : Abs(-60.34) output : 60.34 This function converts a negative value to positive. But has no effect on positive numbers. EXP ( ) : Returns the ex value, where E represents a constant value of 2.718282 Syntax : Exp(<number>) Example: ?Exp(1.0000) output : 2.718282 26
  • 26. S. MADHU MOHAN FOXPRO MAX ( ) : Returns the maximum value of the given numbers. Syntax : Max(<no1><no2>) Example: ?Max(10,13) output : 13 MIN ( ) : Returns the manimum value of the given numbers. Syntax : Min(<no1><no2>) Example: ?Min(10,13) output : 10 ROUND ( ) : Rounds a number to the nearest decimal places specified. Syntax : Round(<no1><no2>) Example : ?Round(60.7389,2) output : 60.74 <no1> is the number to round and <no2> is the no of decimal places is round to. SQRT( ) : (Squire Route) Returns the squire route of the number passed to the function. Syntax : Sqrt (<number>) Example: ?Sqrt (625) output : 25 STRING Functions : This functions are used to make manipulations on strings. ASC( ) : Returns the ASCII value of left, most character of any character string. Syntax : ASC (<character>) Example : ?Asc (“Amar”) output : A=65, a=97 ?Asc(“S”) S=83, s=115 ?Asc(“M”) M=77, m=109 AT ( ) : Returns the starting position of one character string within another character string. Syntax : AT(<character1>,<character2>) Example : AT(“SMM”,”M”) output : 2 CHR ( ) : Returns the ASCII character for a number. Syntax : CHR (<number>) Example : ?CHR(65) output : A 27
  • 27. S. MADHU MOHAN FOXPRO ISALPHA( ) : Determines whether the first character of a string is alphabet. Syntax : ISALPHA (<character>) Example : ?ISALPHA (“ABCDE1”) .T. ?ISALPHA (“124 ABC”) .F. ISLOWER ( ) : Determines whether the first character of a string is lower. Syntax : ISLOWER (<character>) Example : ISLOWER (“mOHAN”) .T. ISLOWER (“Mohan”) .F. STR ( ) : Converts any numeric expression into a character string. Syntax : STR (<number>),([,length>],[<decimal>]) Example : ?STR (1234.56) output : 1235 (10 characters wide) ?STR (1234.56,7,2) output : 1234.56 (7 characters wide) LEFT ( ) : Returns a specified no of characters, starting from the left most position of a string. Syntax : LEFT (<character>,<number>) Example : ?LEFT (“INDIA”,3) output : IND RIGHT( ) : Returns a specified no. of characters, starting from the right most point in a character expression. Syntax : RIGHT(<character>,<number>) Example : ?RIGHT (“INDIA”,3) output : DIA LEN( ) : Returns length of a character string i.e., total no. of characters. Syntax ; LEN (<character>) Example : ?LEN (“MADHU”) output : 5 LTRIM( ) : (Left Trim) Removes leading blanks from a character string. Syntax : LTRIM (<character>) Example : ?LTRIM (“ Mohan”) output : Mohan UPPER( ) : Converts any character expression to upper case. 28
  • 28. S. MADHU MOHAN FOXPRO Syntax : UPPER (<character>) Example : ?UPPWR (“mohan”) output : MOHAN LOWER( ) : Converts any character expression to lower case. Syntax : L:OWER (<character>) Example : ?LOWER (“MADHU”) output : madhu SUBSTR( ) : (Sub String) Substring function, extracts a smaller string from larger string. Syntax : SUBSTR(<character>,<no1>,<no2>) Example : ?SUBSTR(“ANDHRA PRADESH”,8,3) Output : PRA TRIM( ) : Removes trailing blanks from a character string. Syntax : TRIM (<character>) Example : ?TRIM (“MOHAN “) output : MOHAN VAL( ) : Converts numbers stored as character strings to the numeric type. Syntax : VAL (<character>) Example : ?VAL (“1002.34”) output : 1002.34 OTHER FUNCTIONS : BOF( ) : (Beginning of file) Determines whether the beginning of file marker has been reached. Returns .T. If the BOF occurred, otherwise .F. Examples : Use mohan.dbf ?BOF() Skip -1 .F. ?BOF() .T. EOF( ) : Determines whether the end of file marked (beyond) the last record has been reached. Returns .T. If the file pointer is at EOF, other wise .F. Example : Use mohan.dbf or Modi comm. Mohan.prg ?EOF() – .F. Set talk off Goto bottom Clear Skip – 1 Use SMM ?EOF() – .T. Do while .NOT. EOF() ?name, no, total Enddo 29
  • 29. S. MADHU MOHAN FOXPRO DBF( ) : Returns the name of the currently selected data base file. Example : Use mohan.dbf ?DBF() output : Student/mohan.dbf DISK SPACE( ) : Returns the no. of bytes available on the current working Disk Drive. Syntax : Diskspace Example : if(Diskspace>0) ? “Space is available” Else ? “No Space” Endif FOUND( ) : Determines the success of the commands, that were used to search for a particular record. Returns .T. If the most recently given search command is successful. Else .F. Example : Use mohan.dbf Name= “MADHU” Seek= “Name” ?Found() RECCOUNT( ) : (Record Count) Returns the total no. of records in the currently selected data base file. Example : ?RECCOUNT( ) REPLCIATE( ) : Repeats a character string a specified no. of times. Syntax : REPLICATE(<character>,<number>) Example : ?REPLICATE(“*”,6) output : ****** SPACE( ) : Creates a character string composed of a specified no. of blank. Syntax : SPACE (<number>) Example : ?”MADHU”+SPACE (2)+”MOHAN” Output : MADHU MOHAN (madhu two spaces mohan) VERSION( ) : Returns the character expression containing the version no. of FoxPro in use. 30
  • 30. S. MADHU MOHAN FOXPRO Syntax : VERSION( ) Example : ?VERSION( ) Output : FoxPro 2.6 or Visual FoxPro 5.0 TEXT …. ENDTEXT : The “Text…Endtext” command can be used to more off any block of the text for display on screen or printer. Syntax : Text <Text to be display> Endtext Example: TEXT 1. Adding New Employer 2. Deleting Employer 3. Editing Empoyer 4. Exit ENDTEXT STORE : Store command is used assign values into one or more memory variables. Syntax : Store <expre>to[<mem varia 1>][<mem varia 2>] Examples : Store 1000 to Number Store Krishna to Name Store SQRT(25) to no Store Replicate(“-“,80) to line Store “Welcome”+” to India” to message Store CTOD(“23/10/78”) to C_Date Store CTOD_D_Date to Diff_Dates Store 30+20 to no1, no2, no3. 22. Write a Program to accept a Customer name, meter no, present reading, previous reading, unit cost. Find total units, bill amount. Solution : MODI COMM ELECTRICITY.PRG Set talk off Clear Store space(20) cname Store 0 to mno,pre,prv,cost, tou,bill @6,15 say “Enter Customer Name :” get name @7,15 say “Enter Meter Number :” get mno @8,15 say “Enter Present Reading :” get pre @9,15 say “Enter Previous Reading :” get prv @10,15 say “Enter Cost per Unit :” get cost Tou=Pre – Prv Bill=Tou*cost @12,15 say “Total Number of Units :” get tou 31
  • 31. S. MADHU MOHAN FOXPRO @14,15 say “Total Bill Amount :” get bill ^w 23. Write a program to create a data base file with fields sno, sname, dos, unix, total, average. create link dbf and prg files. Solution : MODI COMM LINK.PRG Create Mohan.dbf Set talk off sno n 5 Set safe off sname c 20 Clear dos n 3 Store “y” choice unix n 3 Use mohan.dbf total n 3 Store space(20) to name average f 5,2 Store 0 to no, m1,m2,tot,avg Store Replicate(“-“,79) to line Do while choice= “y” Clear @2,32 say “SMM COMPUTERS” colo *+g/w @3,40 say “NANDIKOTKUR” colo *+r/w @7,15 say “Enter Student Number :” get no Read Index on sno to no Seek no If found( ) Wait window “Student already exists” Else @8,15 say “Enter Student Name :” get name @9,15 say “Enter Marks in Dos :” get m1 @10,15 say “Enter Marks in Unix :” get m2 Read Tot=m1+m2 Avg=tot/2 @12,15 say “Total Marks :” +str(tot) @12,15 say “Average Marks :’ +str(avg) Endif Append Blank Replace sno with no Replace sname with name Replace dos with m1 Replace unix with m2 Replace total with tot Replace average with avg @20,15 say “Continue (Y/N0 :” get choice Read Clear Enddo ^w 24. Write a program to accept student number. If number is not found display message “no Not exists”. Else display name, word, excel, ppt, total, average. 32
  • 32. S. MADHU MOHAN FOXPRO Solution : MODI COMM STUDENT.PRG Set talk off Set safe off Clear Store “y” to choice Use mohan.dbf Store space(20) to name Store 0 to no, m1,m2,tot,avg Store Replicate(“*”,79) to line Do while choice= “y” Clear @2,32 say “SMM COMPUTERS” colo *- @3,40 say “NANDIKOTKUR” colo *- @7,15 say “Enter Student Number :” get no Read Index on sno to no Seek no If .Not. Found() output : Wait window “No Not Exists” Do Student Else @9,15 say “Student Name :” +sname Use mohan.dbf @10,15 say “Marks in Oracle :” +str(oracle) list or F3 @11,15 say “Marks in VB :” +str(vb) @12,15 say “Total Marks :” +str(total) @13,15 say “Average Marks :” +str(average) Endif @20,15 say “Continue (Y/N) :” get choice Read Clear Enddo ^w 25. Write a program to accept product number, pname, quantity, prate. Find bill. If bill>500 discount=bill*15/100, else bill<500 discount=bill*5/100. replace all the filedls with the product data base table. Solution : MODI COMM PRODUCT.PRG CREATE PRODUCT.DBF Set talk off pno n 5 Set safe off pname c 20 Clear quantity n 5 Store “y” to choice prate n 5 Do while choice= “y” bill n 5 Store space (20) to name discount n 5 Store 0 to no,qty,rate, bil, dis, nbill net bill n 5 Store Replicate(“=”,80) to line Clear @2,28 say “KAMADHENU SUPER MARKET” colo *- @3,35 say “NANDIKOTKUR” colo *- 33
  • 33. S. MADHU MOHAN FOXPRO @4,28 say “-----------------------------------“ colo *- @8,15 say “Enter Product Number :” get no @10,15 say “Enter Product Name :” get name @12,15 say “Enter Product Qunatity :” get qty @14,15 say “Enter Product Rate :” get rate Read Bil=qty*rate @16,15 say “Bill Amount :” get bil If (bil>500) Dis=bil*15/100 Else If (bil<500) Dis=bil*5/100 Endif Endif Nbil=Bil – Dis @18,15 say “Total Bill amount :” get nbil Use product.dbf Append Blank Repl pno with no Repl pname with name Repl quantity with qty Repl prate with rate Repl bill with bil Repl discount with dis Repl net bill with nbill @20,15 say “Continue (Y/N) :” get choice Read Clear Enndo ^w 26. Write a program to accept a number find whether the number is “prime number or not”. Solution : MODI COMM PRIME.PRG Set talk off Set safe off Clear Store 0 to no, B I=1 Store Replicate(“chr(3)”,40) to line @5,35 say “Finding Prime Number” @6,30 say “------------------------------“ @8,25 say “Enter a Number :” get no Read Do while (i<=no) If(mod(n,i)=0) B=B+1 34
  • 34. S. MADHU MOHAN FOXPRO Endif I=I+1 Enddo If(B<=2) @10,25 say “PRIME NUMBER” +str(no) Else @10,25 say “NOT PRIME NUMBER” +str(no) Endif ^w 27. Write a program to find a string is Palindrome or not. Solution : MODI COMM PALINDROME.PRG Set talk off Clear Store space(20) to string, rstring @5,20 say “Enter String Name :” get string output : Read Do Palindrome Length=len(string) Madhu Mohan P=1 Not palindrome Do while(p<length) Rstring=substr(string,p,1)+rstring Liril P=p+1 Palindrome Enndo If Ltrim(rstring)=Ltrim(string) @7,20 say “This is Palindrome” Else @7,20 say “This is not Palindrome” Endif ^w 28. Write a program to find palindrome number or not. Solution : MODI COMM PALINDROM.PRG Set talk off Clear Store 0 to no, r, reverse, m @5,15 say “Enter Any Numebr :” get no Read I=1 output : M=no palindrome numbers Do while(I<=no) 1,2,3,……….9,11 R=mod(no,10) Reverse=(reverse*10)+R Not palindrome numbers No=Int(no/10) 10,12,13,199. I=I+1 Enddo If (reverse=M) @6,15 say “Palindrome Number” Else 35
  • 35. S. MADHU MOHAN FOXPRO @6,15 say “Not Palindrome Number” Endif 29. Write a program to handling two data base files. Solution : STD_ADDRESS.DBF STD_MARKS.DBF Sno n 4 sno n 4 Address1 c 20 sname c 20 Address2 c 20 foxpro n 3 Scourse c 10 internet n 3 Total n 3 Average f 5,2 MODI COMM MOHAN.PRG Set talk off Set safe off Clear Close all Use Std_marks Index on sno to no Select B Use Std_address Select A Index on sno to no Store “y” to choice Store 0 to no, m1, m2, tot, avg Store space(20) to name, add1, add2, course Do while choice= “y” @2,32 say “SMM COMPUTERS” colo *+gb/w @3,40 ssay “NANDIKOTKUR” colo *+gr/w @4,32 say Replicate(“chr(7),80) colo *+r/w @7,15 say “Enter Student Number :” get no Read Seek no If Found() Wait window “Number Exists” +no or (name) Else @8,15 say “Enter Student Name :” get name @9,15 say “Enter FoxPro Marks :” get m1 @10,15 say “Enter Internet Marks :” get m2 @11,15 say “Enter Course Name :” get course @12,15 say “Enter Area Name :” get add1 @13,15 say “Enter Village Name :” get add2 Read Tot=m1+m2 Avg=tot/2 @15,15 say “Total Marks :” +str(tot) @17,15 say “Average Marks :” +str(avg) Append Blank 36
  • 36. S. MADHU MOHAN FOXPRO Repl sno with; repl sname with name; repl foxpro with m1; repl internet with m2; repl total with tot; repl average with avg Select B Append Blank Repl sno with no; repl address1 with add1; Repl address2 with add2; repl scourse with course Endif @18,15 say “---------------------------------------“ @20,25 say “Continue (Y/N) :” get choice Read Clear Enddo ^w 30. Write a program to display ASCII characters of given numbers. Solution : MODI COMM ASCII.PRG Set talk off Clear Store 0 to no @5,15 say “Enter Any Number :” get no Read K=chr(no) ?k ^w 31. Write a program to print ASCII numbers. Solution : MODI COMM ASCII.PRG Set talk off Clear Store space(1) to A @5,15 say “Enter a character :” get A Read K=Asc(A) ?K ^w 32. Write a program to print a string this format. Solution : MODI COMM STRING.PRG output : Set talk off Do string Set clock on M Clear MO M=1 MOH Store space(20) to string MOHA @5,15 say “Enter String Name :” get string MOHAN Read | ?left(string,m) L=Len(string) | m=m+1 Do while(M<=L) | enddo 37
  • 37. S. MADHU MOHAN FOXPRO 33. Write a program to print reverse of given numbers. Solution : MODI COMM REVERSE.PRG Set talk off Clear Store 0 to no, I, reverse @5,15 say “Enter any number :” get no Read P=1 output : Do while (p<=no) Do Reverse I=mod(no,10) Enter number : 199 Reverse=((reverse*10)+I) 199 : 991 No=int(no/10) Enddo ?reverse ^w 34. Write a program to print reverse of of A.B.( A value=B, B value=A). Solution : MODI COMM MADHU.PRG Set talk off Clear Do madhu Input “A value :” to A A value : 25 Input “B value :” to B B value : 50 ? “A value :”, B output : ? “B value :” A A value : 50 Set talk on B value : 25 ^w 35. Write a program to print n numbers, and print average of n numbers. Solution : MODI COMM AVERAGE.PRG Set talk off Clear A=1 Tot=0 Input “How many number :” to n Do while(a<=n) Input “x=” to x Tot=tot+x A=a+1 Enndo Avg=tot/n ? “Average of numbers :”, avg Set talk on ^w 36. Write a program to Armstrong number or not. Solution : MODI COMM ARMSTRONG.PRG Set talk off 38
  • 38. S. MADHU MOHAN FOXPRO Clear Store 0 to no @5,15 say “Enter any number :” get no Read X=no Arm=0 Do while(no=0) Rem=mod(no,10) Arm=arm+rem+rem No=Int(no/10) Enddo If x=Arm @7,20 say “Armstrong Number” Else @7,20 say “Not Armstrong Number” Endif ^w 37. Write a program to print inverse pyramid format. Solution : MODI COMM PYRAMID.PRG Set talk off Clear Row=5 Column=5 C=15 For I=10 to 1 step -1 For J= I to 1 step -1 @row,column say Ltrim(str(J)) Column=column+4 Endfor Row=row+1 C=c-2 Column=c @20,6 say “MOHAN” Endfor ^w 38. Write a Program to print concentric boxes. Solution : MODI COMM BOXES.PRG Set talk off Clear Set colo to *- R1=0 R2=24 C1=0 C2=79 Do while(R1<=12) @r1,c1 to r2,c2 double 39
  • 39. S. MADHU MOHAN FOXPRO R1=r1+1 C1=c1+1 R2=r2-1 C2=c2-1 Enddo @3,25 say “HELLO! GOOD MORNING” colo w/rb++ @6,20 say “MADHU MOHAN” colo w/gr++ ^w 39. Write a program to accept a number. If number exists in bdf file, display his name and course. Solution : MODI COMM MOHAN.PRG Choice= “y” Do while choice= “y” Set talk off Set clock on Set safe off Clear Store 0 to no Store space (1) to c Use mohan.dbf Index on sno to no @8,15 say “Enter number to Delete :” get no Read Seek no If Found() @10,15 say “Student Name :” +name @12,15 say “Course Name :” +course @14,15 say “Balance Fee :’ +str(balance) @16,15 say “Do you want to delete :” get c Read If c= “y” Locate for sno=no Delete Pack Endif Else Wait window “Number not exists” Endif @20,20 say “Continue (Y/N) :” get choice Read Clear Enddo ^w 40
  • 40. S. MADHU MOHAN FOXPRO ARRAYS An array is a series of memory variables containing related data. The memory variable has a subscript number to identify individual elements. A single dimensional array contains a row or column of elements, but a two dimensional array contains values in cells made of several rows and columns. DECLARE / DIMENSION : Any of the two commands can be used to create an array. Dimension / Declare is used to declare an array. OBF( ) ----- COUNT( ) ----- Copy to Array <Array name> This command copies the records from the data base file to the array whose names specified. Single Dimension Array : A single dimension array contains row or column of elements. But a two dimensional array contains values in cells made of several rows and columns. 40. Write a program to accept 10 values to an array and print them. Solution : MODI COMM ARRAY.PRG Set talk off Clear I=1 Dimension A(10) For I=1 to 10 Input “Enter Value :” to A(I) Endfor ? ? For I=1 to 10 ? A(I) Endfor ^w ARRAY FUNCTIONS ASCAN( ) : This function does the search operation by using the array name and the value to search for as parameters. It returns row number in which the value exists and returns zero, if search is unsuccessful. 41
  • 41. S. MADHU MOHAN FOXPRO ALEN( ) : Returns the length of an array. The optional (<expre>) expression is an number between 0 to 1. 0 – number of element in the array. 1 – returns no of rows. 2 – returns no of columns. Syntax : ALEN(array name[<expre>]) Example : ALEN (A(5,2)) ADEL( ) : This function deletes values from on array. Syntax : ADEL (array name [<expr>][,(2)]) <expr> denotes the row number of the column number to dleted. ASORT( ) : This function sorts on array in the ascending order by default. Syntax : ASORT(array name[expr n1, expr n2, expr n3]]]) <expr n1> denotes the row to start sorting from. <expr n2> denotes no of rows to sort. <expr n3> denotes the number 0 or 1. To start an ascending or descending order. Example : ASORT (ABC,2,9,1) 2 – starting row 9 – no. of rows 1 – descending order. ACOPY( ) : Copies contents of the array1 to array2. if array 2 does not exists, it creates an array with same dimensions as array 1. Syntax : ACOPY (array1, array 2) 41. Write a program to accept 5 values. Find the numbers are “even or odd” and print sum of even or odd. Solution : MODI COMM SMM.PRG Set talk off Clear Store 0 to I, evensum, oddsum, test, E, O Declare A(5) For I=1 to 5 step 1 Input “Enter values :” to A(I) Endfor For I=1 to 5 step 1 42
  • 42. S. MADHU MOHAN FOXPRO Test=Mod(a(I),2) If test=0 Do Number E=E+1 Enter value : 2,4,9,44,99 Evensum=evensum+A(I) output : Else Even Nos=3(2,4,44) O=O+1 Evensum=50(2+4+44) Oddsum=oddsum+A(I) Endif Odd Nos=2(9,99) Endfor Oddsum=108(9+99) ? “Even Numbers :”, E ? “Sum of Even Numbers :”, evensum ? “Odd Numbers :”, O ? “Sum of Odd Numbers :”, oddsum ^w 42. Write a program to accept 5 numbers. Find big number and small number from given number. Solution : MODI COMM BIG.PRG Set talk off Clear Declare A(5) Store 0 to I,big,small For I=1 to 5 Input “Enter Numbers :” to A(I) Endfor Small=A(I) For I=1 to 5 Do Big If A(I)> big Enter Numbers : Big=A(I) 2,4,9,44,99 Endif Endfor Big Number : 99 For I=1 to 5 Small Number : 2 If A(I)<small Small=A(I) Endif Endfor ? “Big Number :”, big ? “Small Number :”, small ^w 43. Write a program to multiplication of matrix. Solution : MODI COMM MATRIX.PRG Set talk off Clear Dimension A(2,2), B(2,2), C(2,2) Store 0 to I, J For I= 1 to 2 43
  • 43. S. MADHU MOHAN FOXPRO For J= 1 to 2 Input “Enter 1st Matrix values :” to A(I,J) * Next J Endfor Do Matrix * Next I 1st matrix : Endfor 3,4,5,2 For I=1 to 2 For J=1 to 2 2nd matrix : Input “Enter 2nd Matrix values :” to B(I,J) 6,12,6,7 Endfor Endfor 3*6 4*12 ? 5*6 2*7 ? ? “Multiplication of Matrix” 18 48 For I= 1 to 2 30 14 For J= 1 to 2 C(I,J)=A(I,J)*B(I,J) output : ??C(I,J) 18,40,30,14 Endfor Endfor ^w 44. Write a program to accept name, no, course, fees, paid. Find balance and link program file. Solution : MODI COMM SMM.PRG CREATE FEES.DBF Set talk off name c 20 Set safe off number n 5 Clear course c 8 Store 0 to no, feepay fee n 8 Store “y” to choice, option paid n 8 Do while option= “y” balance n 8 Use fees.dbf Index on sno to no @5,20 say “Enter Student Number :” get no Read Seek no If Found() @7,20 say “Student Name :” +name @8,20 say “Course Name :” +course @9,20 say “Actual Fee :” +str(fee) @11,20 say “Do you want to pay fee (Y/N) :” get choice Read If choice= “y” @16,20 say “Enter Fee Paying :” get feepay Read Repl paid with paid+feepay Repl balance with balance – feepay Endif 44
  • 44. S. MADHU MOHAN FOXPRO Else Wait window “Number not exists” Endif @20,20 say “Do you want to continue (Y/N) :” get option Read Clear Enddo ^w 45. Write a program to accept your name and display in ASCII values. Solution : MODI COMM SMM.PRG Set talk off Clear Store 0 to L,A Accept “Enter any Name :” to name L=Len(name) Do smm For A= 1 to L Enter name : MADHU L=substr(name,A,1) ?C=ASC(C) output Endfor 77,65,67,72,85 ^w 46. Write a program to accept employee number, name, designation, salary. Calculate bonus by manager=20%, accountant=!5% on salary, clerk=1000 rs, others=600 rs. Solution : MODI COMM BONUS.PRG CREATE BONUS.PRG Set talk off eno n 5 Set safe off ename c 20 Set colo on designation c 15 Set echo off salary n 6 Clear bonus n 6 Store “y” to choice netsalaray n 10 Do while choice =”y” Store 0 to no, sal, bon, netsal Store space(20) name, desig Clear @2,30 say “BUSINESS MANAGEMENT” @3,37 say “NANDIKOTKUR” @4,30 say “------------------------------------“ @6,15 say “Enter Employee Number :” get no @8,15 say “Enter Employee Name :” get name @10,15 say “Enter Designation :” get design @12,15 say “Enter Basic Salary :” get sal Read If desig= “manager” Bon=sal*20/100 Else 45
  • 45. S. MADHU MOHAN FOXPRO If design= “accountant” Bon=sal*15/100 Else If desig= “clerk” Bon=1000 Else If design= “others” Bon=600 Endif Endif Endif Endif @15,15 say “Bonus Amount :” get bon Netsal=sal+bon @18,15 say “Net salary :” get netsal Use bonus.dbf Append Blank Repl eno with no; repl ename with name; repl designation with design; Repl salary with sal; repl bonus with bon; repl netsalary with netsal @20,20 say “Do you want to continue (Y/N) :” get choice Read Clear Enddo ^w BOX : Draws a box using specified co-ordinates. Syntax : @<row1>,<column1>,<row2>,,colimn2> box <expr c> expression of character. Example : Box program Modi comm. Box.prg Set talk off Clear @3,24, 6,52 box @4,26 say “SMM COMPUTERS” colo *rg/b+ @5,34 say “NANDIKOTKUR” colo *rg/b+ ^w Examples: @10,20 , 12,20 box replicate(chr(22),9) @3,24, 6,52 box “*” @16,24, 18,52 box * @3,24 , 6,52 box replicate(190),2 @3,22 to 6,53 double colo *gr/o+ DOUBLE : If double is included, the box is drawn with a double line border. 46
  • 46. S. MADHU MOHAN FOXPRO Example : modi comm. Double.prg Set talk off Clear @3,22 to 6,53 double colo +rb/b* @4,26 say “SMM COMPUTERS” @5,34 say “NANDIKOTKUR” ^w PANEL : “Panel” is included, the box is drawn with a solid border. Example : modi comm. Panel.prg Set talk off Clear @3,22 to 6,53 panel @4,26 say “SMM COMPUTERS” @5,34 say “NANDIKOTKUR” ^w 47. Write a program display the menu bar. Solution : MODI COMM MENU.PRG Set message to 23 center Set talk off Define menu “SMM” Define pad pad1 of smm prompt “File” at 11,7 On pad pad1 of smm activate popup pop1 Define popup pop1 from 1,1 to 6,14 (or) 12,15 to 16,14 Define bar1 of pop1 prompt “<NEW” Define bar2 of pop1 prompt “<OPEN” Define bar3 of pop1 prompt “<SAVE” Define bar4 of pop1 prompt “E<XIT” On selection bar1 of pop1 do mm1 On selection bar2 of pop1 do mm2 On selection bar3 of pop1 do mm3 On selection bar4 of pop1 do mm4 Activate menu smm ^w 48. Write a program display the menu bar. Solution : MODI COMM MENU.PRG Set talk off Define menu “SMM” Define pad pad1 of smm prompt “ST<UDENT” colo +rb/gr+ Define pad pad2 of smm prompt “<FEES” colo +rb/gr+ Define pad pad3 of smm prompt “<DELETE” colo +rb/gr+ 47
  • 47. S. MADHU MOHAN FOXPRO On pad pad1 of smm activate popup pop1 On pad pad2 of smm activate popup pop2 On pad pad3 of smm activate popup pop3 Define popup pop1 Define popup pop2 Define popup pop3 Define bar1 of pop1 prompt “<ADD” Define bar2 of pop1 prompt “<OPEN” Define bar3 of pop1 prompt “E<XIT” Define bar1 of pop2 prompt “<PAYMENTS” Define bar2 of pop2 prompt “<TOTAL FEES” Define bar1 of pop3 prompt “<STUDENT” On selection bar1 of pop1 do mm1 On selection bar2 of pop1 do mm2 On selection bar3 of pop1 do mm3 On selection bar1 of pop2 do mm4 On selection bar2 of pop2 do mm5 On selection bar1 of pop3 do mm6 Activate menu smm ^w 49. Write a program to print concentric box. Solution : MODI COMM CONENTRIC.PRG Set talk off Clear Set colo to gr R=1 C=30 Do while R<8 @R,C say “*” R=R+1 C=C-2 Enddo R=18 C=17 Do while R<16 @R,C say “*” R=R+1 C=C+2 Enddo R=1 C=30 Do while R<8 48
  • 48. S. MADHU MOHAN FOXPRO @R,C say “*” R=R+1 C=C+2 Enddo R=8 C=43 Do while R<16 @R,C say “*” R=R+1 C=C-2 Enddo R=1 C=30 Do while R<8 @R,C say “*” R=R+1 C=C-2 Enddo Set colo to Set colo to rb+* @8,25 say “SMM COMPUTERS” Set colo to ^w 50. Write a program to accept cname, no, code, item, weight, rate, quantity. Find total, discount, netbill. Solution : MODI COMM AGRI.PRG Set talk off Set safe off Set colo on Clear T=time() @4,15 say t colo +gr/b D=date() @4,60 say d colo +gr/b Choice= “y” Do while choice= “y” Clear Store space(20) to cname Store space(12) to item Store 0 to no, code, weight, rate, quantity, total, discount, net_bill @1,1 to 23,77 chr(3) colo +g/w+ @2,25 to 7,58 double @3,30 say “AGRI GOLD FORMS LIMITED” colo gr+ @4,31 say “SUPER MARKET DIVISION” colo rb+ @5,32 say “NANDYAL ROAD, KURNOOL” colo r+ @6,37 say “CASH – MEMO” colo bg+ @13,3 get no 49
  • 49. S. MADHU MOHAN FOXPRO Read @12,16 say “Code :” colo g+ @13,16 get Code Read @12,28 say “Item :” colo g+ @13,28 get Item Read @12,42 say “Weight :” colo g+ @13,42 get Weight Read @12,54 say “Rate :” colo g+ @13,54 get Rate Read @12,65 say “Quantity :” colo g+ @13,65 get Quantity Read Total=rate*quantity If(total>1500) Discount=total*20/100 Else If (total>1000 .and. total<1500) Discount=total*10/100 Else Discount=0 Wait window “No Discount” Endif Endif @14,65 to 14,74 @15,30 say “Total :” colo g+ @15,60 say Total @16,30 say “Discount :” colo g+ @16,60 say Discount @17,65 to 17,74 Net_bill=total-discount @18,53 say “Net Bill ……… :” +str(net_bill) colo +g/r @21,46 say “Continue (Y/N) :” get choice colo gb+ Read Clear @21,15 say “Thank You Visit Again” colo gr+ Enddo ^w 51. Write a program to simple designing. Solution : MODI COMM DESIGN.PRG Set talk off Clear Row=4 Column=8 50
  • 50. S. MADHU MOHAN FOXPRO C=8 For I=18 to 1 step -1 For J= I to 1 step -1 @row,column say ltrim(str(J)) Column=column+1 Endfor Row=row+1 C=c+2 Column=c Set colo to gr++ @24,6 say “SMM COMPUTERS” Set colo to Endfor ^w 52. Write a program for simple designing. Solution : MODI COMM DESIGN.PRG Set talk off Clear Set colo to r+* @11,1, 15,79 box* Set colo to +g/b* @13,35 say “MADHU MOHAN” @13,33 say chr(3) @13,47 say char(3) @2,32 to 24,48 colo r* R=1 C=40 Do while R<=12 @R,C say chr(3) colo gr+* R=R+1 C=C-3 Enddo R=13 C=4 Do while R<=24 @R,C say chr(3) colo gr+* R=R+1 C=C+3 Enddo R=14 C=73 Do while R<=24 @R,C say chr(3) colo gr+* R=R+1 C=C-3 Enddo R=1 C=40 51
  • 51. S. MADHU MOHAN FOXPRO Do while R<=13 @R,C say chr(3) colo gr+* R=R+1 C=C+3 ^w Enddo 53. Write a program to calculations of the simple interest, squire root, product, eligible vote. Solution : MODI COMM MADHU.PRG Set talk off Set safe off Clear Option= “y” Do while option= “y” Ch=0 Text CALCULATIONS 1. Simple Interest 2. Squire Root 3. Product 4. Person Eligible for Vote 5. Exit Endtext @9,15 say “Enter your choice :” get ch colo gr/b+* Read Do case Case ch=1 Set talk off Store 0 to P,T,R, amount @11,15 say “Enter Principle Amount :” get P @12,15 say “Enter Time :” get T @13,15 say “Enter Interest Rate :” get R Read Amount=P*T*R/100 @14,15 say “Total Amount :” +str(amount) Case ch=2 No=0 @11,15 say “Enter any number :” get N Read R=N*N @12,15 say “Squire Root value :” +str(R) Case ch=3 Store 0 to N,M,R @11,15 say “Enter First Number :” get N @12,15 say “Enter Second Number :” get m 52
  • 52. S. MADHU MOHAN FOXPRO Read R=N*M @14,15 say “Product Result :” =str(R) Case ch=4 Store 0 to age @11,15 say “Enter Voter Age :” get age Read If age<18 @13,15 say “You are not Eligible for Vote” Else @13,15 say “You are Eligible for Vote” Endif Otherwise Wait window “Thank you” Exit End case @20,15 say “Do you want to continue (Y/N) :” get option Read Clear Enddo ^w 54. Write a program to accept a number. Find factorial value of given number. Solution : MODI COMM FACTORIAL.PRG Set talk off Clear Fact=1 Input “Enter a number :” to N For I= to N Fact=fact*I ?Fact Endfo ^w 55. Write a program to print multiplication tables. Solution : MODI COMM MULTIPLICATION.PRG Set talk off Set safe off Clear Store 0 to N @5,10 say “Enter a number :” get N Read M=1 Do while m<=n I=1 Do while I<=10 R=M*I 53
  • 53. S. MADHU MOHAN FOXPRO ?M, “X”, I, “=” R Read I=I+1 Enddo | M=M+1 Clear | Enddo Read | ^w 56. Write a program to accept a number to converted string. Solution : MODI COMM CONVERT.PRG Set talk off Set safe off Store “ ” to J,S Store 0 to A, I Clear Accept “Enter a number :” to N L=Len(N) For I=1 to L J=substr(N,I,1) If J= “1” S=s+ “one” Else If J= “2” S=s+ “two” Else If J= “3” S=s+ “three” Else If J= “4” S=s+ “four” Else If J= “5” S=s+ “five” Else If J= “6” S=s+ “six” Else If J= “7” S=s+ “seven” Else If J= “8” S=s+ “eight” Else If J= “9” S=s+ “nine” Else If J= “0” S=s+ “zero” Endif Endif 54
  • 54. S. MADHU MOHAN FOXPRO Endif Endif Endif Endfor Endif ^w Endif Endif output : Endif Enter number : 23 Endif Two three 57. Write a program to accept product name, manufacturing date, product price, local tax. Find selling price, profit. Solution : MODI COMM PRODUCT.PRG Set talk off Set safe off Clear Ch= “y” Do while ch= “y” Clear Store space(15) to pname Store space(8) to date Store 0 to price, tax, sp, pro, np Store space(1) to choice @3,3 to 9,60 double @5,10 say “Enter Product Name :” get pname @6,10 say “Enter Manufacturing Date :” get date @7,10 say “Enter Actual Price :” get price @8,10 say “Entre Local Tax :” get tax Read Sp=price+tax Pro=tax @10,10 say “Product Name :” +pname @11,10 say “Manufacturing Date :” +date @12,10 say “Actual Price :” +str(price) @13,10 say “Local Tax :” +str(tax) @14,10 say “Selling price :” +str(sp) @15,10 say “Profit Amount :” +str(pro) Np=np+pro @17,10 say “Net profit :” +str(np) @18,10 say “Do you want to continue (Y/N) :” get ch Read Clear Enddo ^w 58. Write a program to accept a exponent number. Solution : MODI COMM EXPONENT.PRG Set talk off Set safe off Clear 55
  • 55. S. MADHU MOHAN FOXPRO Store 0 to N, E Input “Enter Your Number :” to N Input “Enter Your Exponent Number :” to E A=1 B=N Do while a<E Enddo N=N*B ? “Your Number is ……”, to N A=A+1 ^w 59. Write a program to calculate the results of “n” number of students. Solution : MODI COMM SMM.PRG Set talk off Set safe off Clear Store 0 to M @10,15 say “Enter a Number :” get M Read A=1 Do while a<=M Store 0 to m1,m2,tot,avg Store space(20) to name @12,15 say “Name of the Student :” get name @13,15 say “Enter Marks in FoxPro :” get m1 @14,15 say “Enter Marks in Internet :” get m2 Read A=a+1 Clear Tot=m1+m2 Avg=tot/2 @13,15 say “Name of the Student :” get name @14,15 say “Enter Marks in FoxPro :” get m1 @15,15 say “Enter Marks in Internet :” get m2 @17,10 to 23,50 panel colo g+/r+* @19,20 say “Total Marks : get tot @20,20 say “Average Marks :” get avg Wait “SMM COMPUTERS” Clear Enddo ^w 60. Write a program to print a diagram of “Robot” and using special characters. Solution : MODI COMM ROBOT.PRG Set talk off Set safe off Clear Do while .T. Close all Clear all @2,25 tp 6,35 56
  • 56. S. MADHU MOHAN FOXPRO Set colo to /w* @4,28 say “♥” @4,32 say “♥” Set colo to r+/b+ @5,30 say “↔↔” Set colo to @7,29 say “ ” @8,22 to 15,38 Set colo to r++ @15,23 say “«»«»«»«»«»«»«»«»” Set colo to @9,30 to 14,30 @15,22 to 22,26 @15,34 to 22,38 @22,22 say “∇∇∇∇” @22,34 say “∇∇∇∇” @1,26 say “¥” @1,33 say “¥” @2,26 say “¥” @1,33 say “¥” @8,38 to 13,42 @13,39 say “п п п” @8,18 to 13,22 @13,19 say “п п п” Store 0 to A Set colo to g++ Store “HAPPY BIRTH DAY TO U” to N L=Len(N) Do while A<=L @5,36 say left(N,A) ?chr(7) A=A+1 Enddo Set colo to **************** @9,39 clear to 14,45 @5,36 clear to 5,65 @8,38 to 9,50 @8,51 say “≡” @9,51 say “≡” Store 0 to A Set colo to gr++ Store “HAPPY NEW YEAR WISHES TO U” to N L=len(n) Do while A<=L @9,53 say left(N,A) 57
  • 57. S. MADHU MOHAN FOXPRO ?chr(7) A=A+1 Enddo Set colo to **************** @,39 clear to 9,76 @15,40 clear to 15,75 @3,37 to 8,41 @3,38 say “±±±” Store 0 to A Set colo to bg++ Store “HELLO, I AM MADHU’S HELPER” to N L=len(N) Do while A<=L @2,43 say left(N,A) ?chr(7) A=A+1 Enddo Set colo to **************** @2,40 clear to 2,75 @3,37 clear to 8,50 Clear Enddo Set colo to ^w 61. Write a program to designing. Solution : MODI COMM DESIG.PRG Set talk off Set safe off Clear Store 10 to N Set colo to w*/b+ R1=2 C1=15 R2=22 C2=60 Do while n>=6 @R1,C1,R2,C2 R1=R1+2 C1=C1+5 R2=R2-2 C2=C2-5 N=N-1 Enddo Set colo to r*/w+ @12,27 say “SMM COMPUTERS” colo g+/gr++ 58
  • 58. S. MADHU MOHAN FOXPRO ^w 62. Write a program to accept principle, time, rate. Find interest. Solution : MODI COMM INTEREST.PRG Set talk off Set safe off Clear Store 0 to P, T, R Input “Enter Principle :” to P Input “Enter Time :” to T Input “Enter Rate :” to R SI=P*T*R/100 @15,20 say “Interest Amount :” get si ^w 63. Write a simple program. Solution : MODI COMM MADHU.PRG Set talk off Clear Store 0 to I,N Accept “Enter any message :” to mess Input “Enter you limit :” to N ? “S R A A C LTD” Do while I<N ?mess I=I+1 Enddo ? “Thank you” ^w 64. Write a simple program. Solution : MODI COMM MOHAN.PRG Set talk off Clear Store 0 to M,N Input “Enter any number :” to M Input “Enter another number :’ to N Do while M=>N If M%2=0 ?M Endif M=M-1 Enddo ^w 65. Write a simple program. Solution : MODI COMM SMM.PRG 59
  • 59. S. MADHU MOHAN FOXPRO Set talk off Clear Input “Enter Your Limit :” to N I=1 Sum=0 Do while I<=N Input “Enter a Number :” to A Sum=sum+A I=I+1 ? “The average is :”, average Average=sum/N Enddo ? “The sum of N is :”, sum ^w 66. Write a simple program. Solution : MODI COMM MOHAN.PRG Set talk off Clear Store 0 to N,M Input “Enter any two numbers :” to N,M Your no :” to N Do while N<=100 ? N N=N+1 Enddo ^w 68. Write a designing program. Solution : MODI COMM DESIGN.PRG Set talk off Clear Row=2 Column=8 output : C=8 5 4 3 2 1 For I=20 to 1 step -1 4 3 2 1 For J= I to 1 step -1 3 2 1 @row, column say ltrim(str(J)) 2 1 Column=column+2 1 Endfor Row=row+1 C=c+2 Column=c Endfor ^w 69. Write a program for the required format. Solution : MODI COMM DESIGN.PRG Set talk off Clear Row=2 60
  • 60. S. MADHU MOHAN FOXPRO Column=8 output : C=8 5 4 3 2 1 For I=18 to 1 step -1 4 3 2 1 For J= I to 1 step -1 3 2 1 @row, column say ltrim(str(J)) 2 1 Column=column+2 1 Endfor Row=row+1 C=c+4 Column=c Endfor ^w 70. Write a program to print a name that 200 times. Solution : MODI COMM NAME.PRG Set talk off Set safe off Clear For I=1 to 20 For J=1 to 40 For k=1 to 200 ?? “SMM COMPUTERS” Endfor Endfor Endfor ^w 71. Write a program to accept cname, mno, pre, prv, total units, bill amount. If total units>=400 amount 6/- , tu>=300 and tu<400 amount=5/-, tu>=250 and tu<300 amount=4/-, tu>=200 and tu<250 amount=3/-, tu>=150 and tu<200 amount=2/-, tu>=100 and tu<150 amount=1.50/-, tu<=100 amount=1/-. Solution : MODI COMM METER.PRG Set talk off Clear Accept “Enter Customer Name :” to cname Input “Enter Meter Number :” to mno Input “Enter Present Reading :” to pre Input “Enter Previous Reading :” to prv Tu=pr-pv If(tu>=400) Bill=tu*6 ? “Number of Units :”, tu ? “Total Bill Amount :”, bill Else If(tu>=300 .and. tu<400) Bill=tu*5 ? “Number of Units :”, tu ? “Total Bill Amount :”, bill 61
  • 61. S. MADHU MOHAN FOXPRO Else If(tu>=250 .and. tu<300) Bill=tu*4 ? “Number of Units :”, tu ? “Total Bill Amount :”, bill Else If(tu>=200 .and. tu<250) Bill=tu*3 ? “Number of Units :”, tu ? “Total Bill Amount :”, bill Else If(tu>=150 .and. tu<200) Bill=tu*2 ? “Number of Units :”, tu ? “Total Bill Amount :”, bill Else If(tu>=100 .and. tu<150) Bill=tu*1.50 ? “Number of Units :”, tu ? “Total Bill Amount :”, bill Else If(tu<300) Bill=tu*1 ? “Number of Units :”, tu ? “Total Bill Amount :”, bill Else Endif Endif Endif Endif Endif Endif Endif Set talk on ^w 71. Write a program to accept population. Popu>=100000000, country; popu>=10000000 .and. popu<100000000, state; popu>=500000 .and. popu<1000000, district; popu>=50000 .and. popu<100000, taluq; popu>=5000 .and. popu<50000, mandal, otherwise village. Solution : MODI COMM POPULATION.PRG Set talk off Clear Input “Enter Total No. of Population :” to po If(po>=100000000) ? “Country :”, po Else If(po>=10000000 .and. po<100000000) 62
  • 62. S. MADHU MOHAN FOXPRO ? “State :”, po Else If(po>=100000 .and. po<1000000) ? “District :”, po Else If(po>=50000 .and. po<100000) ? “Taluk :”, po Else Endif If(po>=5000 .and. po<50000) Endif ? “Mandal :”, po Endif Else Endif ? “Village :”, po Set talk on Endif ^w 72. Write a program to print Students application. Solution : MODI COMM APPLICATION.PRG Set talk off Clear Accept “Enter Application Number :” to AN Accept “Enter Student Name :” to snmae Accept “Enter Father Name :” to fname Accept “Enter Your Address :” to add Accept “Enter Your Date of Birth :” to dob Accept “Enter Qualificaiton :” to qua Accept “Enter Course Name :” to cou Accept “Enter Fees :” to fee Accept “Enter Date of Joining :” to date Accept “Enter Place :” to pla Clear @2,3 to 24,60 double colo g+/r @3,19 say “SMM COMPUTERS” colo gr+ @4,12 say “Near College Road, NANDIKOTKUR – 518401” colo rb/i @5,4 say “--------------------------------------------------“ colo r+ @6,5 say “App no :” get an colo w+/br @6,45 say “Fee :” get fee colo w+/br @7,49 to 11,58 @9,50 say “Photo” colo gr+/b @8,4 say “1. Name of the Student :” get sname @9,4 say “2. Father’s Name :” get fname @10,4 say “3. Address :” get add @11,31 say “NANDIKOTKUR” colo +gr/w @12,31 say “KURNOOL DIST” colo +r/w @13,4 say “4. Date of Birth :” get dob @14,4 say “5. Education :” @15,7 say “Qualification :” get qua @16,4 say “6. Course Name :” get cou @19,4 say “7. Date of Joining :” get date @19,31 say “Signature of the Student” @20,4 say “8. Place :” get pla 63
  • 63. S. MADHU MOHAN FOXPRO @21,31 say “Signature of the Director” @22,40 say “with seal” ^w REPORT Report displays or prints reports under the control of a report definition file created with “modify report” or “create report”. The default extension for a report definition file is “.FRX” How to Create Report : First Method : Create Report file name Create Report Mohan.frx To run report from command window. Run Report <file name> Run Report mohan.frx Run Report mohan preview Second Method : ♥ Ðèþ$$…§æþ$V> FoxPro ¯èþ…§æþ$ JMæü .dbf òœOÌŒý¯èþ$ ™èþÄæý*Ææÿ$ ^óþÄæý$ÐèþËÄæý$$¯èþ$. ♥ ™èþÆ>Ó™èþ command window ¯èþ…§æþ$ "create report <filename>" (dbf file name). Ex : CREATE REPORT MADHU ♥ madhu.frx A¯óþ window ÐèþçÜ$¢…¨. ♥ C糚yæþ$ Pg HeaderÌZ Title CÐéÓÍ. (SMS Computers) ♥ Details ÌZ cursor¯èþ$ MìüÏMŠü ^óþíÜ Report Menu ÌZ Filed option ¯èþ$ MìüÏMŠü ^óþÄæý*Í. ♥ Expr...... ° MìüÏMŠü ^óþíÜ Field Names ¯èþ$ double click ^óþÄæý*Í. ♥ ò³OÑ«§æþ…V> JMöPMæüP Field ¯èþ$ òÜÌñýMŠüt ^óþÄæý*Í. ♥ C糚yæþ$ Pg Footer ÌZ MìüÏMŠü ^óþíÜ Report Menu ÌZ Field Select ^óþíÜ Expr.... ¯èþ$ double click ^óþÄæý*Í. 64
  • 64. S. MADHU MOHAN FOXPRO ♥ Report Expression window ÌZ Calculate ò³O MìüÏMŠü ^óþíÜ Ðèþ$¯èþMæü$ M>ÐèþËíܯèþ Bç³Û¯Œþ¯èþ$ òÜÌñýMŠüt ^óþíÜ OK A¯éÍ. Ðèþ$äå OK A¯éÍ. ♥ Ctrl + W (Save) ^óþÄæý*Í. ♥ Report Form Madhu to Madhu.txt ♥ !Edit madhu.txt ò³O Ñ«§æþ…V> Report ¯èþ$ ™èþÄæý*Ææÿ$^óþÄæý*Í. To Modify a Report : Modify Report <report name> Modify Report mohan.frx Last : Report format mohan preview. LABEL Label displays or prints labels under the control of a label definition file created with “modify label” or “create label”. The default extension for a label definition file is “.LBX” First Method : 1. Create data base file. Ex : create mohan.dbf 2. create label file Ex : create label mohan.lbx 3. Ctrl+E 4. Ctrl+W 5. Ctrl+w (save) 6. Run menu, select label. Second Method : ♥ Ðèþ$$…§æþ$V> FoxPro ¯èþ…§æþ$ JMæü .dbf òœOÌŒý¯èþ$ ™èþÄæý*Ææÿ$ ^óþÄæý$ÐèþËÄæý$$¯èþ$. ♥ ™èþÆ>Ó™èþ command window ¯èþ…§æþ$ "create label <filename>" (dbf file name). Ex : CREATE LABEL MADHU ♥ madhu.lbx A¯óþ window ÐèþçÜ$¢…¨. 65
  • 65. S. MADHU MOHAN FOXPRO ♥ C糚yæþ$ label menu Expression ¯èþ$ MìüÏMŠü ^óþíÜ Field Names ¯èþ$ double click ^óþÄæý*Í. ♥ ò³OÑ«§æþ…V> JMöPMæüP Field ¯èþ$ òÜÌñýMŠüt ^óþÄæý*Í. ♥ Ctrl + W (Save) ^óþÄæý*Í. ♥ Label Form Madhu to Madhu.txt ♥ !Edit madhu.txt ò³O Ñ«§æþ…V> Label ¯èþ$ ™èþÄæý*Ææÿ$^óþÄæý*Í. ℘℘℘ S. MADHU MOHAN M.A., PGDSE & DHE. 66