Basics of Visual FoxPro Programming

51

Click here to load reader

description

best to students who are new in fox pro programming.

Transcript of Basics of Visual FoxPro Programming

Page 1: Basics of Visual FoxPro Programming

The Basics Of Visual FoxPro

Page 2: Basics of Visual FoxPro Programming

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.

Page 3: Basics of Visual FoxPro Programming

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

Page 4: Basics of Visual FoxPro Programming

What To Learn in Visual Fox Pro cont.

• Delete and Recall Command– Pack Command– Zap Command– Recall Command

• Run Command• Set Default

Page 5: Basics of Visual FoxPro Programming

What To Learn in Visual Fox Pro cont.

Creating Control Objects

ProjectDatabaseTableFormReportMenu

Page 6: Basics of Visual FoxPro Programming

What To Learn in Visual Fox Pro cont.

Building Control Objects and its Properties

TextboxCommand ButtonOption GroupCheck BoxCombo BoxList BoxPage frameImage frameTimer

Page 7: Basics of Visual FoxPro Programming

What To Learn in Visual Fox Pro cont.

Basic Codes of FoxPro

AddSaveDeleteSearchNext ButtonBack ButtonTimer

Page 8: Basics of Visual FoxPro Programming

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.

Page 9: Basics of Visual FoxPro Programming

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.

Page 10: Basics of Visual FoxPro Programming

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.

Page 11: Basics of Visual FoxPro Programming

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.

Page 12: Basics of Visual FoxPro Programming

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.

Page 13: Basics of Visual FoxPro Programming

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

Page 14: Basics of Visual FoxPro Programming

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>

Page 15: Basics of Visual FoxPro Programming

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>

Page 16: Basics of Visual FoxPro Programming

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

Page 17: Basics of Visual FoxPro Programming

Working with Command Window

Delete and Recall Command

Zap- This command is used to erases all records of

active databaseexcept its structure.

Syntax:Zap

Page 18: Basics of Visual FoxPro Programming

Working with Command Window

Delete and Recall Command

Recall- This command is used to unmark the

specified record which wasmarked for deletion.

Syntax:Recall

Page 19: Basics of Visual FoxPro Programming

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]

Page 20: Basics of Visual FoxPro Programming

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]

Page 21: Basics of Visual FoxPro Programming

Creating Control Object

Project

From the menu click File

Select New

Select Project then New File

Page 22: Basics of Visual FoxPro Programming

Creating Control Object

Project Manager

Page 23: Basics of Visual FoxPro Programming

Creating Control Object

Table

From the menu click File

Select New

Select Table then New File

Page 24: Basics of Visual FoxPro Programming

Creating Control Object

Table

Page 25: Basics of Visual FoxPro Programming

Creating Control Object

Form

From the menu click File

Select New

Select Form then New File

Page 26: Basics of Visual FoxPro Programming

Creating Control Object

Form

Page 27: Basics of Visual FoxPro Programming

Creating Control Object

Report

From the menu click File

Select New

Select Form then New File

Page 28: Basics of Visual FoxPro Programming

Creating Control Object

Report

Page 29: Basics of Visual FoxPro Programming

Creating Control Object

Menu

From the menu click File

Select New

Select Form then New File

Page 30: Basics of Visual FoxPro Programming

Creating Control Object

Menu

Page 31: Basics of Visual FoxPro Programming

Building Control Objects

Textbox Option ButtonCommandButton

CommandGroup

Combo Box

Check Box

Image

List Box Timer

Page Frame

Fig.1.1 Form Controls of VFP

Page 32: Basics of Visual FoxPro Programming

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.

Page 33: Basics of Visual FoxPro Programming

Building Control Object

Text Box Properties

Alignment: center

PasswordChar: *

BackStyle: 0-TransparentBorderStyle: 0-None

Page 34: Basics of Visual FoxPro Programming

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.

Page 35: Basics of Visual FoxPro Programming

Building Control Object

Command Button Properties

Caption: Save

Picture:

Page 36: Basics of Visual FoxPro Programming

Building Control Object

Option Group

You can use a group of option buttons to provide a selection of predetermined choices.

Page 37: Basics of Visual FoxPro Programming

Building Control Object

Option Group Properties

Value =:0

BackStyle: 0- TransparentBorderStyle: 0- None

Caption: Yes/No

Page 38: Basics of Visual FoxPro Programming

Building Control Object

Check Box

You can use a check box to switch between three states, True (.T.), False (.F.), and Null

(.NULL.).

Page 39: Basics of Visual FoxPro Programming

Building Control Object

Check Box

Page 40: Basics of Visual FoxPro Programming

Building Control Object

Combo Box

displays a list of items that you can choose an item from.

Page 41: Basics of Visual FoxPro Programming

Building Control Object

List Box

List boxes provide the user with a scrollable list that contains a number of options or pieces of

information.

Page 42: Basics of Visual FoxPro Programming

Building Control Object

Page Frame

A page frame is a container object that contains pages, which can contain controls.

Page 43: Basics of Visual FoxPro Programming

Building Control Object

Image

is a graphical control that displays bitmaps that can't be changed directly.

Page 44: Basics of Visual FoxPro Programming

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.

Page 45: Basics of Visual FoxPro Programming

Basic Codes of Fox Pro

ADD

select item2append blankthisform.txticode.setfocusthisform.refresh

Page 46: Basics of Visual FoxPro Programming

Basic Codes of Fox Pro

Save

With thisformSelect item2Append blankReplace icode with thisform.txtcode.valueThisform.refreshendwith

Page 47: Basics of Visual FoxPro Programming

Basic Codes of Fox Pro

Delete

WITH thisformselect item2 deletethisform.refreshENDwith

Page 48: Basics of Visual FoxPro Programming

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

Page 49: Basics of Visual FoxPro Programming

Basic Codes of Fox Pro

Next Button

select item2if !eof() thenskip+1thisform.refreshelsemessagebox("end of Records")goto topthisform.refreshendif

Page 50: Basics of Visual FoxPro Programming

Basic Codes of Fox Pro

Back Button

select item2if !bof() thenskip-1thisform.refreshelsemessagebox("beggining of Records")goto topthisform.refreshendif

Page 51: Basics of Visual FoxPro Programming

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