Chapter 5 Programming Constructs

There are three programming constructs in any programming language:

Sequence
It is the order in which commands are executed.  Default sequence is the top to bottom, left to right.

Selection
Selection permits selective execution of commands, depending on whether a given condition is satisfied or not.  Syntax:

If <Condition>
<commands -- - - - --1>
else
<commands -- - - - --2>
end if

Where else part is optional and can be omitted.  Commands between if – end if will be executed only of condition is satisfied otherwise next statement is executed.

For every if there must be an end if.  Every end if is matched with the nearest unmatched if.  Example:

Set talk off
Set stat off
No1=0
Not2=0
@ 10,10 say “Enter No 1” get No1
@ 12,10 say “Enter No 2” get No2
read
if No1>No2
@ 15,10 say “No1 is Greater”
else
@ 15,10 say “No2 is Greater”
endif
wait

Do Case—End case
FoxPro evaluates case condition in the sequence they appear.  When case condition is found to be true.  Commands are executed and control moves to next statement following end case.  Hence only one of the command sequences will be executed at a time.  In a Do-Case many case conditions can be included.

Command sequence following otherwise will be executed only if none of the case conditions are true.  Otherwise and default command sequences are optional.  Every Do—case must have an Endcase.  For Example:
Set talk off
Store 1 to Mchoice
@ 10,10 get mchoice function ‘*Add; Mod; Delete’; Default1
Read
Do Case
Case Mchoice =1
@ 20,10 say “Add”
Case Mchoice =2
@ 20,10 say “Mod”
Case Mchoice =3
@ 20,10 say “Delete”
EndCase
Return

Iteration
If particular command sequence is to be repeated then an iteration construct is used.  Such constructs are called as Loops.  Syntax:
Do while <Conditon>
Commands - - - - - -
End do

If the condition is satisfied the loop is entered and commands are executed.  The commands are executed till the condition is true.  When condition becomes false the control exits the loop and executes next command following End do.  Initially if the condition is not satisfied the loop is skipped.  For Example:
Mnum=1
Do while Mnum <=10
? Mnum
Mnum = Mnum+1
Enddo

Scan – EndScan
Scan – Endscan loop specifically used for processing table files.  For Example:
            Use Flights
Do while .T.
Display
Skip
Enddo
Use

Do while loop does not terminate automatically when end of file is reached.  While Scan—EndScan loop automatically terminates when end of the file is reached.  Record pointer is automatically moved to next record in a Scan—EndScan loop so skip command is not specified.  For Example:
Use Flights
Scan
Display
EndScan
Use

Conditions can also be specified for a Scan—EndScan loop.  Only records which satisfy the condition will be processed.  For Example:
            Use Flights
Scan for Source= “Bombay”
Display
EndScan
Use

Exit command can be used within Scan—EndScan loop.  Which forces the control to Exit from the loop.

For Endfor
If number of times a loop is to be executed is known , For—EndFor Loop can be used.  For Example:
            For n = 1 to 10
            ? n
            Endfor

The File Maintenance Programs are
·         Add
·         Modify
·         Delete

Example 1:- Program to add a record in a database
set talk off
set safe off
use stu_marks
mmark1=0
mmark2=0
mmark3=0
mtotal=0
mpercent=0
@ 12,10 say "enter student id no:-"get mst_id          
@ 13,10 say "enter standard:-" get mstd
@ 14,10 say "enter hindi marks:-" get mmark1
@ 15,10 say "enter english marks:-" get mmark2
@ 16,10 say "enter marathi:-" get mmark3
read
mtotal=mmark1+mmark2+mmark3
mpercent=mtotal/3

appe blank
repl st_id with mst_id
repl std with mstd
repl mark1 with mmark1
repl mark2 with mmark2
repl mark3 with mmark3
repl total with mtotal
repl percent with mpercent

Assignments  (Add Records in a Database)
1)      Accept name, Designation, Dept, Salary and Calculate DA, TA, HRA PF, ESIC and NETSAL and add the record in Employee table.
2)      Accept Flight_code, Flight_Date, Source, Destination, Depart_Time, Depart_Date and add the record in the Flight Table.
3)      Accept Pass_Name, Passport_No, Flight_Code, Padd_Add, Tel_No, Destination, Fare and Add the record in the Passenger Table.
4)      Accept Salesman, Salesman_No, Area, Salary, Sales and calculate commission as if Sales is greater than Rs. 20000/- Comm = 5%, if sales is >15 and <20000 then Comm=4%, if sales is >10000 and <15000 then Comm = 3%.  And add the record in the Sales table.

Example 2:- Program to Modify Existing Record in a Database.
set talk off
set safe off
use stumark
index on st_id tag std
mst_id=0
mstd=0
mmark1=0
mmark2=0
mmark3=0
mtotal=0
mpercent=0
@ 10,10 say "the student id nomber to modify" get mst_id
read
seek mst_id

if not found()
@ 13,10 say "such no does not exit"
endif

if found()
mst_id=st_id
mstd=std
mmark1=mark1
mmark2=mark2
mmark3=mark3
mtotal=total
mpercent=percent
@ 15,10 say "the standard is:-" get mstd
@ 16,10 say "hindi is:-" get mmark1
@ 17,10 say "english is:-" get mmark2
@ 18,10 say "marthi is:-" get mmark3
read
mtotal=mmark1+mmark2+mmark3
mpercent=mtotal/3

repl st_id with mst_id
repl std with mstd
repl mark1 with mmark1
repl mark2 with mmark2
repl mark3 with mmark3
repl total with mtotal
repl percent with mpercent
repl result with mresult
endif

Assignments (Modifying Records in the table)
1)                  Write a program to modify records in a Flight Table.
2)                  Write a program to modify records in a Passenger Table.
3)                  Write a program to modify records in a Sales Table.
4)                  Write a program to modify records in a Employee Table.
5)                  Write a program to modify records in a Stu_Mark Table.

Assignments (If—End if Programs)
1)                  Accept a Color and display following messages for particular Color.
Black   =          “Sadness”
White  =          “Piece”
Yellow =          “Friendship”
Red     =          “Feelings”
Blue     =          “Vastness”
Else     “Wrong Color Entered”

2)                  Accept Name and Age and display the following messages for the Age entered with the name.
If Age >=20
“Adult and Qualified for Voting”
if Age<20
“Minor Disqualified For Voting”

Example 3:-Program to Delete A Record from the Database.
set talk off
set safe off
use student
index on st_id to stu1
mst_name=space(9)
mst_std=0
mst_id=0
mst_add=space(10)
mad_date={  /  /     }
mst_tele=0
mleave_date={  /  /     }
mdel='y'

@ 9,10 say "the student id to delet" get mst_id
read
seek mst_id

if not found()
@ 11,10 say "record is not exist"
endif

if found()
@ 13,10 say "the employee is:-"+(st_name)
@ 15,10 say "st_std is:-"+str(std)
@ 17,10 say "st_id is:-"+str(st_id)
@ 19 ,10 say "add_date is:-"+dtoc(date())
@ 21,10 say "leave_date is:-"+dtoc(date())
@ 27,25 say "do you wish to delet this record" get mdel
read
endif
if mdel='y'
delet
pack
endif

Assignments (Deleting Records in the table)
1)                  Write a program to Delete records in a Flight Table.
2)                  Write a program to Delete records in a Passenger Table.
3)                  Write a program to Delete records in a Sales Table.
4)                  Write a program to Delete records in a Employee Table.
5)                  Write a program to Delete records in a Student Table.

Counter Variable
Counter variable is that variable which counts the Numeric Value as per the User Requirement.  It can be declared as:
CTR = 0         
CTR = 1

Example 4: -Program to Display “Hello” Five Times
  set talk off
  ctr=1
  r=5
  c=5
  do while ctr<=5
  @ r,c say "hello”
  r=r+1
  ctr=ctr+1
  enddo 

Example 5:-Program to Accept 10 Numbers and to Display its Sum.
set talk off
no=0
sum=0
ctr=2
r=2
c=9
do while ctr<=10
@ r,c say "enter a no" get no
read
ctr=ctr+1
sum=sum+no
r=r+5
c=c+5
enddo
@ 20,10 say "The Sum is " +str(sum)

Example 6:- Program to display a Fibonacci Series.
Set talk off
A=0
B=1
C=0
Ctr=1
R=3
No=0
@ r,10 say “Enter a No” get No
read
do while ctr<=10
C=A+B
@ 22,2 say C
A=B
B=C
Ctr=Ctr+1
R=r+1
enddo

Chapter 3 Managing Files

Modifying Table Structure
Table structure are need to be modified like existing field characteristics, field size and so on.  Such operations can be done:-

Modify Structure or by
Modi Stru

Copying Files
COPY TO command is used to copy selected fields from one table to another table.
Use Fees
Copy to Fees99

Copy to command allows to copy a certain portion of currently selected table file depending on specified condition.
Copy to Fees99 fields RollNo, Fees_paid
Copy to Fess99 Fees_paid>2500

Copying files can be done by specifying file Extensions.
Copy file Marks.DBF to NewMark.DBF

RENAMING
Renaming files can be done using RENAME command.
Rename Marks.DBF to Stu_Ref.DBF.

Erasing File
To erase a file DELETE File command is used with the File Extensions.  Syntax:
Delete File<File Name>
Delete File Fees.DBF.
Delete File Student.DBF

Multiple File Handling
To open multiple files at a time is possible in FoxPro.  FoxPro allows to open more than one table at a time.  Up to 225 files can be opened at a time.  Each open file (Table) is held in a separate Work Area.

Work Area
A work area is simply a place where FoxPro keeps track of a single table and all related information.  By default work areas are numbered from 1 through 225.  After a select command is used to choose a work area, desired table is opened.  For Example:
Select 1
Use Student
Select 2
Use Marks
Any table can be made active by selecting that work area.

Setting Relationship
Relationship can be established between tables with the SET RELATION command. Which draws the relationship between a key field which is common to two or more tables.  The table in second work area must be indexed on field which is used to link the files, before SET RELATION command is used.  For Example:

Select 1
Use Student
Index on RollNo tag StuRoll

Select 2
Use Marks
Index On RollNo tag MkRoll
Set relation to RollNo into Student

Go 3
Display FName, City, RollNo

SET RELATION command is not limited to two tables.  Number of tables can be linked as long as a common key fields is exists between two tables.

When multiple tables are required to be used, fields from different tables can be specified within a command.  For Example:
Go top
List RollNo, Mark1, Mark2, Mark3, Student.FName, Student.City

FoxPro Programming Table Of Contents

Chapter 9 Windows, Screen Builder & Designing Menus


Windows are the presentation tools.  Windows enhance the appearance and use of screen in applications.  Window can be defined as:
Define Window <Window Name> Command.
Window name can be up to 10 characters long. 

Define window W1 from 1,1 to 15,50

Activating/Deactivating Window
Window can be activated or Deactivated by activate and deactivate commands.  Syntax:
Activate/Deactivate Window <Window Name>Command.

Activate Window W1
Deactivate Window W1

Hiding Window
Window can Hide by hide command.  Syntax:
Hide Window <Window Name> Command. 
Hide Window W1.

Physically Removing Window
Windows can be physically removed from the memory by release Window command :-
Release Window <Window Name> Command.
Release Window W1

Clearing All Windows
All Windows can be cleared by Clear Windows Command.

All Commands for Windows are:
Define Window            :           Define window W1 from 1,10 to 10,60.

Activate Window         :           Activate window W1

Deactivate Window     :           Deactivate window W1

Hide Window              :           Hide window W1

Release Window          :           Release window W1

Clear Window             :           Clear Window W1

Title
Windows can be assign title which appears on the top border of the window.  For example:
Define window W1 from 1,1 to 10,60 title “My Windows”
Activate Window W1.


Screen Builder
Screen Builder allows for current data-base environment with screen form to be saved.  Database environment includes all open database, all linkages established with set relation and set skip and also with selected work area. 

Screen Menu
Options on this menu allows to create or modify an input screen definition file quickly.  The options are as follows:

1.      Layout
Displays screen layout dialog where size and position of input screen can be defined.

2.      Size
Used to change height and width of the screen.

3.      Position
Position of screen can be changed.  Center option will center the screen in the middle of main FoxPro Window.

4.      Title
Used to specify text to appear in the screen title bar.

5.      Name
To name the screen.

6.      Options
Screen related options can be summarized as follows:

·         Code         :           Codes or programs can be added through this.
·         Color        :           A wall paper and color can be selected for the screen.
·         Font          :           To set default font for the text and objects on the screen.

Window Style
We can set screen borders and determine whether or not the screen can be moved closed and minimized.  The options or the window styles are as:

Type
Several options like user, system, dialog, alert and environment etc can be chosen to assign predefined attributes and borders for the screen.

Open all Code Snippets
This option opens program editing windows for all code snippets associated with the screen.

Show/Hide position
Displays in status bar the co-ordinates of mouse pointer and dimensions of the selected objects.

Ruler/Grid
Allows to set units of measurement for ruler and change size of alignment grid.

Snap to Grid
An invisible alignment grid is set on so that objects automatically aligned to nearest grid line when they are sized or moved.

Object Order
Opens object order dialog to adjust the order that the objects are accessed in the screen using keyboard.

Designing Menus
Menus in FoxPro can be created either by writing programs or by using Menu-Builder option.  Menu builder is used to link together the application components that we developed working in an command window, which makes them more accessible to users who do not much about computers or FoxPro.  It is mainly a tool for building FoxPro System Menus.  Menu can be created by Create Menu command in the command window. 


Create Menu <Menu Name>
Create Menu Tryone

Modify Menu <Menu Name>   (if menu is already is created)
Modify Menu Tryone


In Menu Design prompt column can be used to specify prompts to be used for each menu pads and pop-ups.  When menu system is generated, pads are displayed on the menu bar in the order in which they are appear in the prompt column.

Submenu
When menu pads are defined submenu is displayed on the result pop-up by default.

Command
It is chosen when menu bar has to carry out a specific command to be executed when the associated menu pad or option is chosen.

Pad Name
It is an option variable when defining prompts at menu bar level and bar # is an option when defining prompts at sub menu level.  In the generated code, menu pads are referred by name and option on a menu pop-up are referred by their number.

Procedure
Can be used to create or edit a procedure.  Procedure command need not be typed as FoxPro generates this command with unique procedure names.

Menu Options
When a prompt is defined for a menu pad or submenu option, the prompt options dialog can be activated.

Comments
Can be added for reference purpose.

Shortcut
Can be used to define short cut key.

Skip for
Can be used to create logical expression which will determine whether pad or option is disabled = (.T.) or enabled =(.F.)

Message
Can be given using message check box.

Pad Name
To specify Pad Name.

Try It
Can be used to preview the Menu

Chapter 8 Reports

Reports can be run within a program with Report form command.  It offers a number of flexible options.  Reports can be created using following options:
Create Report <Report Name>  or by      Report Writer

? Command
? (Single Question Mark) Command used for displaying contents of variables.  It is used to display information on the Screen or Printer.
? “Computer Fundamentals”
? “First Chapter”

Where Single Question mark (?) evaluates expression and displays the result on the next line.

At
AT clause specifies the column number where result is displayed.  AT also allows to position the fields from a database file in the report.
? “Hello World !!” AT 30
The above command will display Hello World!! On the next line at column 30.

?? Command
?? Command (Double Question Mark) displays output on the current line, at the current cursor position.
? “Hello”
?? “Every One”
The Result of the above command is:
Hello Every One

System Memory Variable
All system memory variables are public by default.  They can be declared as private within our programs.  Each system memory variable is used for specific purpose.  Some of these system variables are:
_Wrap = .T.
Wrap causes output of a ? and ?? commands to Word Wrap between Left and Right Margin.
_Alignment = “”
Alignment can be of three values they are:
Right, Left and Center
By default alignment is only Left justified.
_Wrap = .T.
_Alignment = “Center”
? “FoxPro is a Programming Language”

_Lmargin =<ExpN>
Left margin can be set as per user requirement.  It determines the number of columns to be left blank printing the text.
_Lmargin = 4

_Rmargin<ExpN>
Determines number of columns to be left blank to right of the printer text.
_Wrap = .T.
_Lmargin = 4
_Rmargin = 78

_PageNo
Page no determines or sets the current page no on the output.
_PageNo =1

_PageLength
This can be specified to determine the length of the page.  An integer value from 1 to 32767 can be assigned to Plength.
_PageLength = 500
_PLength = 500

Control Break
In a Report it is necessary to group information based in some common criteria.

On Key Command
On Key Command can be used to trap specified key.

On Key label F1 Do Cancel
Syntax for Report is
Report
[Form <File> |?]
[Environment]
[<scope>]
[For <Expl 1>]
[While <Expl 2>]
[Heading <Expl C>]
[NoEject]
[Plain]
[Preview]
[To Printer [Prompt] | To File <File>]
[Summary]

Where
For clause is used to specify condition that must be met for records included in the report.

While condition should used along with an index to specify records to be included in the report while specified condition is true.

Environment option enables FoxPro to use same Environmental Settings that were in effect when report was saved.

Scope is optional (All, Next X, Or Rest) can be used.

Plain option drops system clock data and page numbers.

Heading option followed by a character expression, causes heading to appear at top of each page.

NoEject option cancels form feed that normally occurs when the To Print option is used.

To File option can be used to store output to a text file.

Summary option cancels normal display or printing of detail lines within a report.

Set Filter
Set filter command can be used to provide users with choices of conditions that apply to data printed with a report.  Syntax:

Set Filter to [Condition]
Set Filter to Source = “Bombay”

Line and Column Numbers
_PlineNo determines current line number.  It takes value from 0 through _Plength -1.  Value stored in _PlineNo can not be exceed the value in _Plength.

_PlineNo
Is automatically set to 0 when command Eject Page is used.

_PcolNo
Determines current column number.  Its value automatically incremented by FoxPro as it moves to next column.  Column number can also be set by assigning a value to PColNo.  It can take values from 0 to 255.

Directing Output to Printer
Output of ? and ?? commands are by default sent to Screen.  To direct output to printer the command SET PRINTER ON is used.  It directs all output not formatted by @ -- say to the printer.

SET PRINTER OFF Command directs output back to screen.  If printer is not connected to your system, output can be redirected to file.

Set printer to <File>

Before a report program starts printing the report, it should determine if printer is connected or not and if it is connected, whether it is on-line or not.

PrintStatus( )
This function is used to verify whether printer is connected or not, or whether it is online or offline.  This function returns the logical True if printer is ready to accept output, otherwise it returns logical False value.  So before directing the output to printer it is necessary to check whether printer is ready to accept output.  Output could be redirected to a file after checking for printer status using the PrintStatus() function

If printstatus()
Set print on
Else
Set printer to out.txt                           à        Output to a file
Set printer on                                      à        Output to a Printer
Endif

Reports (Example 1)

Set talk off
Set stat off
Set escape off
Set printer to out.txt
Set printer on
Use FL_Infor Order FL_Code
_Wrap =.T.
_Alignment = “Center”
_Lmargin = 4
_Rmargin=76
_PageNo=1
_Plength=66
? “Flight Details”
_Alignment = “Left”
? “Page No”
?? Ltrim (Str(_PageNo))
_Alignment = “Right”
??”Date :” +DtoC(Date())
_Alignment = “Left”
?Replicate (“-“,85)
***************Column Headings***************
?   ”Flight Code” At 5
?? ”Flight Date” At 20
?? “Eco Seats” At 40
?? “ Exe. Seats” At 65
?Replicate (“-“,85)
Scan
?  Flight_Code At 5
?? Flight_Date At 20
?? Eco_Seats At 40
?? Exe_Seats At 65
EndScan
?Replicate (“-“,85)
Wait Window
Clear
Use
Set print off
Set printer to
Set escape on
Return

Page Breaks
In multi page reports, column headings may need to be displayed on every page.  After printing one page the printer must be advanced to next page.  The PAGE HANDLER command specifies the command to be executed when a particular line number is reached.  Usually procedure is executed when a particular line is reached.  This procedure is used to advance the printer to the next page and print the column headings on the new page.

ON PAGE [at Line <ExpN> Command>]
FoxPro executes the specified command when value in _PLineNo is greater than the number specified in he At Line Clause while executing ? and ?? commands.

Disabling Page Handler
On page command disables page handler, so it must be specified while resetting the environment at the end of the programs.  Example:
à        On Page At Line 60 do NewPage

Procedure NewPage will be executed if the value in _PlineNo is greater than 60.  Procedure NewPage will be used to advance the printer to a new page (Eject Page)and print the page number and column headings.

Example 2
Set talk off
Set stat off
Set escape off
Set printer to out.txt
Set printer on
Use Flights
On Page AT Line 60 do NewPage
_Wrap =.T.
_Alignment = “Center”
_Lmargin = 4
_Rmargin=76
_PageNo=1
_Plength=66
? “Flight Details”
_Alignment = “Left”
? “Page No”
?? Ltrim (Str(_PageNo))
_Alignment = “Right”
??”Date :” +DtoC(Date())
_Alignment = “Left”
?Replicate (“-“,85)
***************Column Headings***************
?   ”Flight Code” At 5
?? ”Flight Date” At 20
?? “Eco Seats” At 40
?? “ Exe. Seats” At 65
?Replicate (“-“,85)
Scan
?  Flight_Code At 5
?? Flight_Date At 20
?? Eco_Seats At 40
?? Exe_Seats At 65
EndScan
?Replicate (“-“,85)
Wait Window
Clear
Use
On Page
Set print off
Set printer to
Set escape on
Return

Procedure NewPage
_Alignment = “Center:
? “Flight Report “
Eject Page
?   ”Flight Code” At 5
?? ”Flight Date” At 20
?? “Eco Seats” At 40
?? “ Exe. Seats” At 65
?Replicate (“-“,85)

On Page command is used to handle page breaks.

Duplicate Copies
Printing can be repeated to print more copies of the same Reports.  The following commands are used to establish these commands.

PrintJob ----EndPrint Job
All commands used for printing must be enclosed within printjob and endprintjob.  All system variables can be defined before the printjob.

Printjob--- Endprintjob is an iteration construct, loops as many times as the value in a system memory variable _PCopies.  _PCopies contains the number of copies between the range of 1-----32767.  Syntax:
* Define after System Memory Variables.
_PCopies =  5
PrintJob
* Commands to Print Entire Report
EndPrintJob

Thus there are Five copies of the report with the _PCopies =5)

Control Break Programs
The Control breaks can be of two types Single Level Control break and Double Level Control Break.

Single Level Control Break
In a report it may sometimes be necessary to group information based on some common criterion.  The grouping on a single field is called as single level control break where only one field is the controlling field.  Syntax:

Use Flights
Scan
If not Control Break
Print Record
Add 1 to total Bookings, Final Total
Else
Print Total
Initialize Total Bookings to 0
Print Record
Endif
Endscan
Print Total Bookings, Final Total

Double Level Control Break
When a report is grouped on a more than one field it is called as double level control break.
Syntax:

Use Flights
Scan
If not Major Break
Print Record
Add up number of Bookings
Else
Print Total Bookings
Add Total Bookings Total to Final Total
Initialize Bookings Total to 0
Print Record
Add 1 to Bookings Total
Add Bookings Total to Final Total
Initialize Bookings Total to 0
Print Bookings Total
Initialize Bookings Total to 0
Print Record
Add 1 to Bookings Total
Endif
Endscan
Print All Totals
Print Final Total

Example(Single Level Control Break)
Set talk off
Set stat off
Clear
Use Salary
Index on dept tag dept1
Gtot =0
Mdept =space(15)
Subtot =0
Mdept=dept
Do while not EOF()
? “Name of Employee” At 5
?? “ Salary Drawn “ At 20
Do while Mdept = dept
? Name At 20
?? Basic At 40
Subtot= Subtot +Basic
Skip
Enddo
? “Total of Dept “ + Mdept + str (Subtot)
Mdept =Dept
Gtot =Gtot +Subtot
Subtot =0
Enddo
? “Grand Total “ +str(Gtot)

Example(Single Level Control Break)

Set talk off
Set stat off
Set safe off
Clear
Use Salesman
Index on Region tag Region1
Index on Name tag Name1
Mctr=0
Tctr=0
R =4
MRegion =space(25)
MName=space(25)
Do while not EOF()
? “Ponds India Ltd” At 30
? “ Region Wise Report of the Sales Man “ AT 25
MRegion=Region
Do while MRegion =Region
? “Region “At 5
?? “Name” At 15
?? “Sales Man “ At 35
? Replicate( “_”, 85 )At 4
MName=Name
Do while MName=Name
? Region At 5
?? Name At 15
?? SalesMan At 35
Mctr= Mctr+Salesamt
Skip
Enddo
?Replicate(“-“, 85) At 5
? “Total Sales Conducted in one Region “ +str(Mctr)
Tctr = Tctr+Mctr
Mctr=0
Enddo
? “Total Sales Amount in Region “ +str(Tctr)
?Replicate(“-“, 65) At 10
Wait
Gctr=Gctr+Tctr
Tctr=0
Enddo
?Replicate(“-“, 85) At 5
? “Grand Total Of Sales Amount in Region “ +str(Gctr)

1)         Multiples of 50
Set talk off
Set stat off
Clear
P=0
Ctr=1
Do while Ctr<=500
P = Ctr*50
@2,10 say “Multiples of 50 “
?? P
Ctr = Ctr+1
Enddo

2)         Multiples of 4
Set talk off
Set stat off
Clear
No=1
P=1
Ctr=1
R=4
Do while Ctr<=100
P=No*4
Ctr =Ctr+1
No = No+1
@ 2,10 say “Product is “ +str(P)
@ r,10 say “Multiples of 4 is “
r=r+1
if r>=30
r=4
clear
endif
enddo

3)         Print a Reverse No
Set talk off
Set stat off
Clear
Dime A[10]
No=0
i=1
Do while i< =10
A[i]=0
@ 5,7 say “Enter No “ get A[i]
Read
i = i+1
enddo
i=10
do while i>=1
@ 9,7 say “Reverse of the Number is” get A[i]
wait
i = i-1
enddo

4)         Program to Print
*
*          *
*          *          *
*          *          *          *
*          *          *          *          *
Set talk off
Set stat off
Clear
No=1
No1=1
R=4
C=60
Do while No<=5
No1=1
Do while No1<=No
@ R,C say “*” Pict “!”
C=C-5
No1= No1+1
Enddo
R=R+1
No=No+1
C=60
Enddo

Assignments
·         Accept height and base of a Triangle and print its Area.
·         Accept height, base of Radius and print Area of a Circle.
·        Accept a year from the user and print whether it is a Leap Year or not by using Mod(Year/4=0) function.
·   Accept two numbers and accept an Operators like /, +, -, * and print appropriate messages and answers.
·         Accept length, breadth or the rectangle and print its area.