Basics of Visual FoxPro Programming
Click here to load reader
-
Upload
jovito-delcano-gabion-jr-iii -
Category
Documents
-
view
204 -
download
21
description
Transcript of Basics of Visual FoxPro Programming
The Basics Of Visual FoxPro
Objectives:
• To be able to give basic information about FoxPro
Environment.
• To give an overview about basic VFP commands.
• To give an overview about basic VFP controls.
• To give an overview about basic VFP codes.
What To Learn in Visual Fox Pro
• Working With Command Window– Creating a New Table– Modify the Structure of a Table– Displaying and Editing Data
• Append Command• Browse Command• Replace Command
What To Learn in Visual Fox Pro cont.
• Delete and Recall Command– Pack Command– Zap Command– Recall Command
• Run Command• Set Default
What To Learn in Visual Fox Pro cont.
Creating Control Objects
ProjectDatabaseTableFormReportMenu
What To Learn in Visual Fox Pro cont.
Building Control Objects and its Properties
TextboxCommand ButtonOption GroupCheck BoxCombo BoxList BoxPage frameImage frameTimer
What To Learn in Visual Fox Pro cont.
Basic Codes of FoxPro
AddSaveDeleteSearchNext ButtonBack ButtonTimer
Working with Command Window
The Command window is a Visual FoxPro system window. When you
choose menu commands, Visual FoxPro language commands are echoed in
the Command window.
Working with Command Window
Creating New Table
Syntax :create <table name>
To create a table file from command window type the
word CREATE followed by the name of the table file, and
press Enter key.
Working with Command Window
Modify the Structure of a Table
Syntax:Modify Structure
From the command window we can modify the structure by
typing the MODIFY STUCTURE command.
Working with Command Window
Displaying and Editing Data
Working from the command window, we can USE a table and then type one of the following:
•APPEND to display the table in Append mode.
•BROWSE to display the table in browse mode.
•REPLACE to change the contents in more than one record.
Working with Command Window
Displaying and Editing Data
APPEND - This command is used to add records to the active database file.
Syntax:AppendAppend Blank
APPEND Blank - will add a blank record at the bottom of the screen.
Working with Command Window
Displaying and Editing Data
Browse - This is a powerful editing command provide us facility to edit records horizontally with
showing us multiple records at a time.
Syntax:Browse
Working with Command Window
Displaying and Editing Data
Replace - This is a powerful editing
command. This is used to replace a new
value in a field with or without a condition.
Syntax:Replace <field> with <expr1>
Working with Command Window
Delete and Recall Command
Replace - This is a powerful editing
command. This is used to replace a new
value in a field with or without a condition.
Syntax:Replace <field> with <expr1>
Working with Command Window
Delete and Recall Command
Pack - This command is used to physically remove
all those records whichwas marked for deletion.
Syntax:Pack
Working with Command Window
Delete and Recall Command
Zap- This command is used to erases all records of
active databaseexcept its structure.
Syntax:Zap
Working with Command Window
Delete and Recall Command
Recall- This command is used to unmark the
specified record which wasmarked for deletion.
Syntax:Recall
Working with Command Window
Run command
We can execute any DOS command or non Visual
FoxPro program without quitting from Visual FoxPro.
Syntax:Run [/n]
Working with Command Window
Set Default
Visual FoxPro uses its default drive and directory
forcreating files, unless we specify the path separately.
Syntax:Set Default To [cPath]
Creating Control Object
Project
From the menu click File
Select New
Select Project then New File
Creating Control Object
Project Manager
Creating Control Object
Table
From the menu click File
Select New
Select Table then New File
Creating Control Object
Table
Creating Control Object
Form
From the menu click File
Select New
Select Form then New File
Creating Control Object
Form
Creating Control Object
Report
From the menu click File
Select New
Select Form then New File
Creating Control Object
Report
Creating Control Object
Menu
From the menu click File
Select New
Select Form then New File
Creating Control Object
Menu
Building Control Objects
Textbox Option ButtonCommandButton
CommandGroup
Combo Box
Check Box
Image
List Box Timer
Page Frame
Fig.1.1 Form Controls of VFP
Building Control Object
Text Box
The text box is the basic control that allows users to add or edit data in a Character, Numeric, or Date
field in a table.
Building Control Object
Text Box Properties
Alignment: center
PasswordChar: *
BackStyle: 0-TransparentBorderStyle: 0-None
Building Control Object
Command Button
is typically used to start an event that performs an action such as closing a form, moving to a different
record, printing a report, and so on.
Building Control Object
Command Button Properties
Caption: Save
Picture:
Building Control Object
Option Group
You can use a group of option buttons to provide a selection of predetermined choices.
Building Control Object
Option Group Properties
Value =:0
BackStyle: 0- TransparentBorderStyle: 0- None
Caption: Yes/No
Building Control Object
Check Box
You can use a check box to switch between three states, True (.T.), False (.F.), and Null
(.NULL.).
Building Control Object
Check Box
Building Control Object
Combo Box
displays a list of items that you can choose an item from.
Building Control Object
List Box
List boxes provide the user with a scrollable list that contains a number of options or pieces of
information.
Building Control Object
Page Frame
A page frame is a container object that contains pages, which can contain controls.
Building Control Object
Image
is a graphical control that displays bitmaps that can't be changed directly.
Building Control Object
Timer
A typical use for the timer is checking the system clock to determine if it is time to run a program or
application.
Basic Codes of Fox Pro
ADD
select item2append blankthisform.txticode.setfocusthisform.refresh
Basic Codes of Fox Pro
Save
With thisformSelect item2Append blankReplace icode with thisform.txtcode.valueThisform.refreshendwith
Basic Codes of Fox Pro
Delete
WITH thisformselect item2 deletethisform.refreshENDwith
Basic Codes of Fox Pro
Search
LOCATE for Icode=ALLTRIM(thisform.textsearch.value)IF FOUND() thenMESSAGEBOX("Icode found")thisform.txtIcode.Value=Icodethisform.txtScode.Value=Scodethisform.txtDescri.Value=Descrithisform.txtPrice.Value=Pricethisform.search.Value=""ELSE MESSAGEBOX("Icode not Found")ENDIFthisform.Refresh
Basic Codes of Fox Pro
Next Button
select item2if !eof() thenskip+1thisform.refreshelsemessagebox("end of Records")goto topthisform.refreshendif
Basic Codes of Fox Pro
Back Button
select item2if !bof() thenskip-1thisform.refreshelsemessagebox("beggining of Records")goto topthisform.refreshendif
Simple Activity
1. Create new project and name it pos2. Create form name as activity3. Create table name as Item4. Input fields:
1. Icode character 32. Scode character 23. Descri character 154. Price numeric 4 decimal: 2
3. Design the GUI4. Command buttons:
1. Add2. Save3. Search4. Next5. Back
5. Place a grid that displays the added item6. Also place a search box for searching item code