Académique Documents
Professionnel Documents
Culture Documents
CONTENTS
Definition
It is the methodical procedure or process, used as a delivery mechanism for providing
specific goods or services to customers in a well defined market.
• All policies and strategies must be discussed with all managerial personnel and
staff.
• Managers must understand where and how they can implement their policies and
strategies.
environment.
• A planning unit must be created to ensure that all plans are consistent and that
policies and strategies are aimed at achieving the same mission and objectives.
All policies must be discussed with all managerial personnel and staff that are required in
the execution of any departmental policy.
Management
Definition
Management in all business and human organization activity is simply the act of getting
people together to accomplish desired goals and objectives. Management comprises
planning, organizing, staffing, leading or directing, and controlling an organization (a
group of one or more people or entities) or effort for the purpose of accomplishing a goal.
Resorting encompasses the deployment and manipulation of human resources, financial
resources, technological resources, and natural resources.
Characteristics of a Manager
• A manager who has opportunity to use of all the tools of management that any
Planning is the ongoing process of developing the business mission and objectives and
determining how they will be accomplished. Planning includes both the broadest view of
the organization, e.g., its mission, and the narrowest, e.g., a tactic for accomplishing a
specific goal.
Staffing is filling and keeping filled with qualified people all positions in the business.
Recruiting, hiring, training, evaluating and compensating are the specific activities
included in the function. In the family business, staffing includes all paid and unpaid
positions held by family members including the owner/operators.
Each of these functions involves creative problem solving. Creative problem solving is
broader than problem finding, choice making or decision making. It extends from analysis
of the environment within which the business is functioning to evaluation of the outcomes
from the alternative implemented.
Levels of Management
Managers at all these levels perform different functions. The role of managers at all the
three levels is discussed below:
LEVELS OF MANAGEMENT
schedules etc.
h. The top management is also responsible towards the shareholders for the
The branch managers and departmental managers constitute middle level. They are
responsible to the top management for the functioning of their department. They devote
more time to organizational and directional functions. In small organization, there is only
one layer of middle level of management but in big enterprises, there may be senior and
junior middle level management.
a. They execute the plans of the organization in accordance with the policies and
d. They interpret and explain policies from top level management to lower level.
e. They are responsible for coordinating the activities within the division or
department.
f. It also sends important reports and other important data to top level management.
h. They are also responsible for inspiring lower level managers towards better
performance.
d. They are also entrusted with the responsibility of maintaining good relation in the
organization.
etc to the higher level and higher level goals and objectives to the workers.
i. They arrange necessary materials, machines, tools etc for getting the things done.
m. They are the image builders of the enterprise because they are in direct contact
Data Handling
This system is the means by which data flows from one person or department to another.
It can encompass everything from inter-office mail and telephone links to a computer
system that generates periodic reports for various users.
Information systems serve all the functions or departments of a business, linking them in
such a way that they effectively work towards the organizational purpose.
Modern organizations have to maintain large volumes of data about various entities
of interest— products, processes, people, customers, competitors, equipment, facilities,
and suppliers.
The performance of the manager can suffer on counts, getting too little information or
getting too much information.
Therefore, it is important to identify what is relevant information for the decision maker.
To accomplish this task, one must have a thorough understanding of the data elements for
the proposed system.
♦ Draw an X through circled items that will not be stored by the new system.
Another technique for identifying elements is brainstorming. Pick an entity and ask
yourself what characteristics (data) describe that entity.
Entity
An entity is a person, place, thing, event, or concept about which information is recorded.
Attributes of Entity
Every entity has some basic attributes that characteristically describe it.
In computer terminology an attribute is often called:
Data element,
Data field or just field,
Data item, or
Elementary item
Data Value
A data value is the actual data or information which the attribute of an entity takes.
It is also referred to as an instance of the attribute.
Example: Relationship between Entity, Attribute, and Data
If these do not match, further processing may be discontinued. Such totals are known
as "Batch/Hash Totals".
• Stored Data
A lot of data are stored in the system in computer files that may be required for
processing purposes at various points in time.
Examples: Employee data
Product data
Sales data
Budget data
Cost data
• Derived Data
Derived data are the result of processing or manipulation of raw or stored data.
Example: Invoice value in an invoice can be determined from quantity sold and unit
price.
Primary key is the key data element that will identify the entity uniquely. With this data
element we can enter other data elements. It is possible that there are two or more data
elements that can uniquely identify an entity.
Example: A student can be identified uniquely both by his/her roll number as well
as student registration number.
Data elements other than the primary data element are called secondary data
elements.
Example: For an invoice, invoice number is the primary key and other details such
as its date, customer number, and value are secondary data elements.
Historical Data
Used for reference and analysis purposes. Organization stores data for planning,
forecasting, and taking different decisions and actions. These actions are largely based on
the historical data.
• Accuracy
It is a ratio of correct information to the total amount of information produced over a
period.
• Reliability
Ensures that system should not produce dangerous or costly failures when it is used in a
reasonable way.
• Timeliness
The value of information also depends on when it is made available to the decision maker
and how quickly system responds to user request for information.
All these qualities of information are major concerns of the information system manager.
Not only the information must be readily available but if not stored properly, intact in a
classified and indexed manner, its retrieval time will be high even for a computer.
• Origination
The first function involved in the processing of data is the original of the data to be
processed. Specifically, the nature, type, and origin of the source documents must be
determined, such as sales orders and purchase orders.
• Data Capture
Data must be recorded or captured in some form or the other before it can be processed.
What data are important and should be collected for input and processing depend upon
the organization and the system.
Data may be captured in paper-forms using source documents and in paper-less forms
through:
♦ Keyboards
♦ Automated Teller Machines
♦ Other direct input devices that accept input data in machine readable form.
• Sorting
Normally, it is easier to work with data if it is arranged in a logical sequence.
Examples: First to last time sequence
Biggest to smallest
Oldest to newest
Arranging classified data in such a sequence is called "sorting".
• Merging
This function allows multiple files to be put together in a sequence, provided the files are
already in sorted order.
Example: A file of new customers could be merged into an existing customer
master file that is stored on a magnetic disk in customer number sequence.
• Calculating
The arithmetic manipulation of data to create meaningful results is known as calculating.
It is a common data processing task.
This process is usually the most significant part of the manipulation operation
because the results are generally provided as part of the output.
• Summarizing
Reducing masses of data to a more concise and usable form is called summarizing.
Generally, the data is summarized into form desired for output.
Example: Pie charts, Bar charts, other graphs
These are few of the many computer-generated graphics that are used to view data at a
glance.
Output
After the various operations on the data have been completed, the delivery or
communication of the information or results must be carried out by:
♦ Reporting, which is the format presentation and distribution of processed data?.
♦ Issuance of documents, such as cheques, invoices, and reports.
Transferring data from one location or operation to another, for use or further
processing, is data transmission. This process continues until information in a usable form
reaches the final user. Sometimes, of course, it is necessary to copy or duplicate output
documents.
Storage
Finally, the results of the processing of data must be retained for future use of reference.
This function is called storage.
data.
Processing Logic
1) Compute salary using basic salary and attendance and leave data. Add
overtime payment to get gross salary.
2) Compute deductions — P.F., income tax, and loan recovery.
3) Compute net salary. Print pay slip, and pay ledger.
Procedures
1) Attendance data for the previous month will be provided by office by the
first of every month.
2) Leave records will be provided by the head of the department in which the
employee works.
3) Input data will be used to update employee record as well as produce various
outputs. The data processing department will process data and distribute the
outputs to the concerned departments.
Supporting data files contain details of all items in the inventory and related costs.
Monetary transactions, receipts and expenditure of funds, are made available to the
financial accounting module through the database and are maintained in journals.
Periodically, journals are used to create basic financial statements, such as:
♦ Balance sheet
♦ Income statement
The process involved in the preparation of these statements rarely goes beyond simple
calculation and report generation.
Computers can process vast quantities of business data at enormous speeds with unfailing
consistency and unimaginable flexibility.
These capabilities of computers open new approaches to problem solving and data
processing.
Following six characteristics of computers make them indispensable for use in business:
• Speed
Computers speed up data processing by many orders of magnitude compared to manual
system.
• Data Volume
Vast amount of data can be stored and processed very quickly.
• Repetitiveness
The more repetitive the task, the more profitable it is to automate it.
• Complexity
Problems with several interacting variables can be solved quickly and accurately.
• Accurate Output
As high accuracy can be obtained as needed; also, accuracy is not affected by boredom
and fatigue and is not subjective.
• Declining Costs
There has been a steady decline in the cost of per unit of data processed.
Data capture is the identification of new data to be input. It is always best to capture the
data as soon as it originates.
The commonly used input device is a keyboard. Mouse, joy stick, light pen, touch screen,
and trackballs are some of the devices which do not require typing of input information.
Online Mode
Following devices are used to capture data online
1) Keyboard
2) Light Pen
3) Mouse
4) Scanners
5) Optical Scanners
6) Terminals
7) Smart Cards
Offline Mode
Offline data entry involves devices through which data is first recorded on some media
and then into the computer.
In almost 90% of the applications, data entry is done offline. This saves the precious
computer processing time.
The data entered by the operator is totaled by the computer. If the two entries do not
match, then it is a clear indication that there is a mistake.
In this manner, only correct data is passed to the machine before processing is done.
• For Output
There are two basic categories of computer-produced output:
♦ Output for immediate use by people, and
♦ Output that is stored in computer-usable form for later use by the computer.
• For Transmission
Data communication is the most exciting development in data processing today.
Communication, the transfer of information, is the basis of office automation.
2) Automated Banking
ATMs are widely used in most banks for better customer service. User can make deposits
and withdrawals, check balances, and even pay utility bills through the machines.
3) Point-of-Sale Terminals
These are used in retail stores in place of cash registers. These terminals send records of
sales to a central computer, which maintains accounting and inventory records.
Concept of Files
Files are documents you can add to your knowledgebase. The type of files you can add is
controlled by the settings of your knowledgebase, but in general you can add graphics,
text documents (Word, Excel, and PowerPoint) or PDF.
The file area is separate to the article knowledgebase, although you can attach the files
from the File area into articles. There are mainly two types of files:
1. Master Files:
A database file, often created manually as needed, that contains static records used to
identify items, customers, vendors, bills of material, work centers, etc. as opposed to files
used to track the dynamic status of orders and inventory balances.
A file of data in which is the principal source of information for a job which is updated or
amended as necessary.
(In computer science) it is a computer file that is used as the authority in a given job and
that is relatively permanent
2. Transaction Files:
A collection of transaction records. The data in transaction files is used to update the
master files, which contain the data about the subjects of the organization customers,
employees, vendors, etc.). Transaction files also serve as audit trails and history for the
organization. Where before they were transferred to offline storage after some period of
time, they are increasingly being kept online for routine analyses.
(In computer science) it is a computer file containing relatively transient data about a
particular data processing task.
File Organization
File organization refers to the relationship of the key of the record to the physical location
of that record in the computer file. The two main objectives of computer-based file
organization are:
The three file organization methods that are commonly used in business data processing
applications are:
• Sequential
• Relative
• Indexed
The selection of a particular file organization depends upon factors like the type of
application, the method of processing for updating files, and size of file.
A sequential file is a file, which consists of the same record types that is stored on a
secondary storage device. The physical sequence of records may be based upon sorting
values of one or more data items or fields.
A computer file storage format in which one record follows another. Records can be
accessed sequentially only. It is required with magnetic tape.
Advantages
• It is the most economical and efficient file organization where the activity ratio
(the ratio of the total number of records in transaction file and the total number
of records in master file) is very high. For this reason, such a file organization is
Disadvantages
• It proves to be very inefficient and uneconomical for applications in which the
• Since an entire sequential file may need to be read to retrieve and update few
• Timeliness of data in the file deteriorates while batches are being accumulated.
• Data redundancy is typically high since the same data may be stored in several
A relative record file contains records ordered by their relative key, that is, the record
number that represents the record location relative to where the file begins. For example,
the first record in the file has a relative record number of 1, the tenth record has a relative
record number of 10, and so forth. The records can have fixed length or variable length.
The record transmission modes allowed for relative files are sequential, random, or
dynamic. When relative files are read or written sequentially, the sequence is that of the
relative
record number.
An indexed file contains records ordered by a record key. Each record contains a field
that contains the record key. The record key uniquely identifies the record and determines
the sequence in which it is accessed with respect to other records. A record key for a
record might be, for example, an employee number or an invoice number.
An indexed file can also use alternate indexes, that is. Record keys that let you access the
file using a different logical arrangement of the records. For example, you could access
the file through employee department rather than through employee number.
The record transmission (access) modes allowed for indexed files are sequential, random,
or dynamic. When indexed files are read or written sequentially, the sequence is that of
the key values.
Advantages
• Permits the efficient and economical use of sequential processing techniques
• Permits direct access processing of records in a relatively efficient way when the
Disadvantages
• These files must be stored on a direct access storage device. Hence, relatively
• Less efficient in the use of storage space than some other alternatives
1. Batch Processing:
Executing a series of non interactive jobs all at one time. The term originated in the days
when users entered programs on punch cards. They would give a batch of these
programmed cards to the system operator, who would feed them into the computer.
Batch jobs can be stored up during working hours and then executed during the evening
or whenever the computer is idle. Batch processing is particularly useful for operations
that require the computer or a peripheral device for an extended period of time. Once a
batch job begins, it continues until it is done or until an error occurs. Note that batch
processing implies that there is no interaction with the user while the program is being
executed.
An example of batch processing is the way that credit card companies process billing.
The customer does not receive a bill for each separate credit card purchase but one
monthly bill for all of that month's purchases. The bill is created through batch
processing, where all of the data are collected and held until the bill is processed as a
batch at the end of the billing cycle.
• It makes each job wait in line at each step and often increases its turn-around
time.
Online Transaction Processing has two key benefits: simplicity and efficiency.
l> Reduced paper trails and the faster, more accurate forecasts for revenues and expenses
are both examples of how OLTP makes things simpler for businesses. It also provides a
concrete foundation for a stable organization because of the timely updating.
2> Another simplicity factor is that of allowing consumers the choice of how they want to
pay, making it that much more enticing to make transactions.
Banking, stock exchanges, stock control, work progress control in plants, and inventory
status
A computer system that functions in such the computer must respond to a way that
information entered at a terminal within a short period of time.
An airline reservation system that must respond with available seats on a flight, or a point
of sale system that must quickly look up stock availability and prices; these are two
examples of real-time systems.
By extension of this concept, real-time in modern usage has come to be used to describe a
very fast response computer system such as one that might be used to control factory
processes.
A real-time system might have a sensor that reads the temperature of a vat of chemicals,
and a method of sending signals to the heater for the vat. As the temperature rises or falls
slightly, the computer switches the heater on and off to keep a consistent temperature in
the vat.
processor, and
The characteristic of real-time data processing that truly distinguishes it from the more
common batch and online processing systems is the immediacy of its response on receipt
of a message. Thus, all online systems are not necessarily real-time data processing
systems.
• Sales analysis master file can be updated online. This file provides a ready
CONCEPT OF PROGRAMMING
Unstructured Programming:
Structured Programming:
Procedural Programming:
Possible Benefits: The ability to re-use the same code at different places in the program
without copying it. An easier way to keep track of program flow than a collection of
"GOTO" or "JUMP" statements. The ability to be strongly modular or structured.
Modular Programming:
PROGRAM DESIGN
Top-Down Approach:
In a top-down approach an overview of the system is first formulated, specifying but not
detailing any first-level subsystems. Each subsystem is then refined in yet greater detail,
sometimes in many additional subsystem levels, until the entire specification is reduced to
base elements. A top-down model is often specified with the assistance of "black boxes"
that make it easier to manipulate. However, black boxes may fail to elucidate elementary
mechanisms or be detailed enough to realistically validate the model.
Bottom-Up Approach:
In a bottom-up approach the individual base elements of the system are first specified in
great detail. These elements are then linked together to form larger subsystems, which
then in turn are linked, sometimes in many levels, until a complete top-level system is
formed. This strategy often resembles a "seed" model, whereby the beginnings are small,
but eventually grow in complexity and completeness. However, "organic strategies", may
result in a tangle of elements and subsystems, developed in isolation, and subject to local
optimization as opposed to meeting a global purpose.
Program Documentation
Introduction
Visual FoxPro is a Relational Database Management System (RDBMS), which allows
you to work with several logically related tables of data simultaneously. A Table in a
database contains a number of Rows and Columns. One row in the table is equivalent to
one record and one column is equivalent to one field.
FoxPro evolved into Visual FoxPro in 1995. It retained its procedural capabilities,
primarily to maintain backward-compatibility, but added tremendously to its professional
stature by becoming a fully realized object-oriented language as well. And, of course,
there were still more development tools to work with! VFP is now in its third major
release, version 6. Its outlook is very much expanded to encompass interaction with other
major desktop and client/server products, and to build Web-based applications.
Objectives
After going through this lesson, you would be able to
• start Visual FoxPro menus
• use shortcut keys
• use Visual FoxPro menus.
• explain the concept of DBMS
A database is a collection of various records comprising rows and columns. One row is
one record and one column is one field. A record is collection of logically related fields
and a field is one-column information. In Visual FoxPro, there can be more than one table
storing different stream of information. A table in a database contains a number of Rows
and Columns. One row in the table is equivalent to one record and one column is
equivalent to one field.
Assuming that you have Visual FoxPro 6 (VFP) installed on your machine, how do you
start it? When VFP installs, it creates a new Windows group called Microsoft Visual
FoxPro and/or installs Visual FoxPro in the Start menu. In Windows NT, this group
appears in the Project Manager. Double-clicking the group icon opens the group window,
revealing an icon named Microsoft Visual FoxPro 6. This icon represents the main
program. In Windows 95, VFP installs a group (now called a folder) in the Programs
menu of the Start button. By default, the program folder gets the name Microsoft Visual
FoxPro. Clicking this option opens another menu level that shows the available programs
installed with Visual FoxPro. These programs correspond to the programs shown in the
Visual FoxPro group window of the Project Manager.
Here we have discussed 6.0 version of Visual FoxPro In order to start with Visual
FoxPro; you must ensure that Visual FoxPro system is already installed on your
computer. To invoke Visual FoxPro, click on start button, then all programs, then
Microsoft Visual Studio 6.0 and the Visual FoxPro 6.0.
The Visual FoxPro window will appear on your screen as shown below.
There are two windows
1. Command Window
2. View Window
1. Menu Bar
A Menu Bar is located at the top of the screen and displays all the available titles for
menu. The content of the menu bar changes when you move from one title to another title
of the menu bar.
3. Menus
When you choose a menu pad from the menu bar by clicking the menu pad, Visual
FoxPro displays a pull-down menu. A Menu is a list of related options displayed in the
pull-down menu. When you choose an option from a menu, Visual FoxPro executes it.
Choosing an option means activating a highlighted option by clicking with mouse or
pressing the <Spacebar> key or <Return> key.
4. Menu Options
When you choose a menu pad from the menu bar, Visual FoxPro displays a pull-down
menu. A pull-down menu contains options. The options on each menu are logically
related to menu pad. To choose a desired menu option you want, use one of the following
methods:
• Move to the menu pad and click. The pull-down menu appears. Click on the
desired option you want.
• Press <Alt> key or <F10> key and then press the underlined letter (hot key) in the
menu pad name. Type the underlined key for the menu option you want.
• Use the Left and Right Arrow keys to the menu pad you want to use and then
press <Return> key. Use the Up and Down arrow keys to select the desired option
and then press the <Return> key or <Spacebar> key.
You will find that some of the menu options have an ellipsis (…) after the option. This
indicates that the option will further open a dialog box. A dialog box appears to request
the additional information.
The File Menu Options: The File menu pop-up list contains options related to accessing
files (creating new files, opening existing ones, closing, saving, and printing). Table 1
describes these options.
New Opens the New dialog box. The options in this dialog box enable you
to create new projects, databases, tables, queries, connections, views,
remote views, forms, reports, labels, programs, classes, text files, and
menus.
Open Opens the Open dialog box, which opens any file type listed under
New.
Close Closes the active window. If you press Shift and open the File menu,
this option becomes Close All, which closes all open windows.
Save Saves the file in the active window with its current name. For a new
file that has no name, the option prompts the user for a filename.
Save As Prompts the user for a new filename before saving the file.
Save As Class Saves the current form or selected controls as a class definition
(active only from within the Form Designer).
Revert Cancels changes made in the current file during the current editing
session.
Page Setup Changes the page layout and printer settings for reports.
Page Preview Displays pages in a window as they will appear when printed.
Print Prints the contents of the current window, a file, or Visual FoxPro's
Clipboard.
<project files if any> Provides quick access to reopen any of the last four opened projects.
Exit Exits Visual FoxPro. Choosing this option is the same as typing QUIT
in the Command window.
The Edit Menu Options The options in the Edit menu provide functions that are used
for editing programs, forms, and reports. This menu also contains options that create
object linking and embedding (OLE) objects. Table 2 lists the options that appear at
various times in the Edit menu pad.
Cut Removes the selected text or object from current document and
places it on the Clipboard.
Copy Makes a copy of the selected text or object and places it on the
Clipboard.
Paste Special Used to insert OLE objects from other applications into a general
field. You can embed objects or merely link them. Visual FoxPro
stores a copy of embedded objects in the current object. When an
object is linked, FoxPro stores a path and name reference to the
original object only.
Select All Selects all objects in the current window. This option is used often
in form and report design to move or format all objects at the same
time.
Find Displays the Find dialog box, which is used to locate text strings in
files. Find options include the capability to ignore case, wrap
around lines, match entire words, and search forward or backward.
Find Again Repeats the last Find starting at the current insertion point position
rather than the beginning of the document.
Replace Displays the Replace dialog box, which is used to locate and
replace text strings in files.
FoxPro programs-right?)
Similar to Paste Special, except that it does not assume that the
Insert Object object already exists and is stored on the Clipboard. The option
embeds objects in general type fields. When chosen, Insert Object
opens the other application without exiting Visual FoxPro. After
creating the object in the other application, Insert Object returns to
Visual FoxPro and inserts the linked or embedded object.
Links Opens linked files (OLE) and enables you to edit the link.
Properties Displays the Edit Properties dialog box, which enables you to
affect the behavior, appearance, and save options of the edit
windows.
Several options from Table 2 -Paste Special, Insert Object, Object, and Links-apply only
to general fields and OLE. The rest of the options apply to editing programs and fields.
The Edit Properties dialog box, opened by choosing the last option in the Edit menu,
gives you control over the editor's many properties. The behavior properties, for example,
turn on and off drag-and-drop editing, word wrap, and automatic indent. (Unless you are
using Visual FoxPro editor as a word processor, I do not recommend using word wrap.)
Finally, you can have VFP make a backup copy of the file when you edit it, compile the
file when it is saved, save line feeds, and create an end-of-file marker.
The View Menu Options The View menu displays options that are appropriate for
viewing the current table, if one is open. If you are not currently viewing a file, the menu
displays a single option (Toolbar) that opens the Toolbar dialog box, which lists the
available toolbars used by Visual FoxPro 6. On the other hand, if you already are
browsing a table or editing a form, menu, or report, additional options appear as described
in Table 3.
Edit Changes to an Edit layout style for viewing and changing records.
The option displays fields vertically, and a horizontal line separates
records (if grid lines are active).
Browse Changes to a Browse layout style for viewing and changing records.
The option displays fields horizontally; rows represent records and
columns represent fields.
Append Mode Appends a blank record to the end of the table and moves the record
pointer to the first field in it.
Data Environment Defines tables and relations used in a form, form set, or report.
Properties Displays the Properties dialog box for forms and controls.
Code Opens the code windows when you are editing object methods.
Form Controls Opens the Form Controls toolbar while you are in the Form
Toolbar Designer.
Report Controls Displays the Report Controls toolbar, which enables you to add
Toolbar controls to a report.
Layout Toolbar Opens the Layout toolbar, which helps you align controls.
Color Palette Opens the Color Palette toolbar, which enables you to select
Toolbar foreground and background colors for a control.
Report Preview Provides buttons that move between pages of the preview, change
Toolbar the zoom factor, print the report, and exit preview mode.
Database Designer Opens the Database Designer, which maintains tables, views, and
relationships stored in a database.
Table Designer Opens the Table Designer, which enables you to make structure
modifications to associated and free tables and to their indexes.
Show Position Displays the position, height, and width of the selected object or
form in the status bar.
General Options Adds code in a menu when you are using the Menu Designer.
Toolbars Displays a dialog box that lists every toolbar used by FoxPro,
enabling you to customize the buttons in toolbars and to create your
own.
The Format Menu Options The Format menu normally consists of options that control
font characteristics, text indentation, and spacing. Additional options become available,
however, when you are using the various Designers, and are described in Table 4.
Reduce Font Reduces the font size used in the current window.
1 1/2 Space Uses 1 1/2-line spacing for the text in the current window.
Unindent Removes the indent of the current or selected lines in the current
window.
Horizontal Spacing Provides options that adjust horizontal spacing between selected
objects.
Vertical Spacing Provides options that adjust vertical spacing between selected
objects.
Bring to Front Moves the selected object to the top of the objects in a form.
Send to Back Moves the selected object to the back of the objects in a form.
Snap to Grid When you are moving objects, repositions the top-left corner to the
nearest grid intersection when the mouse button is released.
Set Grid Scale Determines how far apart the vertical and horizontal grids are.
The Tools Menu Options The Tools menu provides a variety of programmer tools,
ranging from wizards to the debugger. Table 5 defines the options in the Tools menu.
Class Browser Examines the contents of any class to view its properties and
methods or even the actual code used to create the object.
The Macro dialog box enables you to create, edit, and view macro definitions. A macro
definition consists of a series of Visual FoxPro commands that you can store and execute
with a single keystroke. Previously FoxPro provided eight default macro definitions,
which are assigned to function keys F2 through F9. Pressing F5, for example, executes
the command DISPLAY STRUCTURE, which lists the structure of the current table. Table 6
shows the definitions of these default macros.
F3 LIST Lists records from the current table; opens the GETFILE
window if no table is being used.
F5 DISPLAY STRUCTURE Shows the field definitions of the current table; opens the
F6 DISPLAY STATUS Shows the table opens in each area. If an index is also
open, F6 displays its expression. The key also shows the
settings of SET commands and other system information.
In addition to these eight macros, you can define your own. In fact, because you can use a
variety of key combinations to name macros, you can define more than 250 macros at one
time.
The last option in the Tools menu is Options, which displays a multiple-page form that
provides controls to customize the way you work with Visual FoxPro. VFP divides these
controls into 12 distinct groups: Controls, Data, Debug, Field Mapping, File Locations,
Forms, General, Projects, Regional, Remote Data, Syntax Coloring, and View. These
groups are covered in more detail in the section "Setting Configuration Options" later in
this chapter.
The Program Menu Options: The Program menu consists of six options that are related
to compiling and running a program. Table 7 describes the Program options.
Suspend Stops the current program from executing but does not remove it from
memory.
Run Runs the current program. (The option appears in the menu as Do,
followed by the name of the PRG.)
The Do command opens a dialog box that enables you to select the program that you want
to run. (You can also execute a program from the Command window; enter DO
immediately followed by the name of the program that you want to run.) You do not have
to compile a program before running it; you can run a PRG directly. VFP can compile the
program automatically before running it.
Choose Program, Do, and select the program from the Do dialog box, which is similar to
the Open dialog box. The Do option differs from the Run option (which appears in the
menu as Do, followed by the name of the PRG), which executes the program in the
current window.
VFP enables the Cancel option only when you are executing a program. To access this
option, you must suspend the program or be stepping through it in the Trace window.
Visual FoxPro enables Resume only while an executing program is suspended. The
option resumes a suspended program to normal execution mode.
To suspend a program, you first need to interrupt it. You can do this while you are using
the Trace window to step through the program. You can interrupt a program by inserting
breakpoints into the code, using the Trace window, or setting break conditions on
variables or expressions.
The Compile option opens a window similar to the Open dialog box, enabling you to
select a source file. The option takes the selected program source file (PRG) and compiles
it. Click the More>> button to display several additional options related to encryption and
debugging, as well as to create an error file (ERR), if desired.
The Window Menu Options: The Window menu contains options that manage open
windows onscreen. The menu provides options that enable you to Arrange All, Hide,
Clear, and Cycle through windows. In addition, the menu enables you to bring to the front
any window that is currently open. Table 8 lists the Window options.
Hide Hides the active window but does not remove it from memory.
Clear Clears text from the application workspace or current output window.
Cycle Moves from one open window to the next, making the next window the
active one.
Command Window Makes the Command window active and brings it to the top, opening it
if necessary.
Data Session Makes the Data Session window active and brings it to the top, opening
it if necessary. This window serves as a valuable tool for monitoring
which tables are open in each of the 32,767 work areas.
<Window List> Displays the first nine defined windows. If more than nine windows
have been defined, a final option-More Windows-appears. To change
focus to any window, simply click its name.
The Arrange All option resizes open windows to create non-overlapping tiles. Arrange
All will not resize a maximized window. With two open windows, it splits the screen in
half vertically and puts the active window on the left side. With three open windows, it
also splits the screen in half vertically, putting the active window on the left side. The
option then splits the right half horizontally, however, to display the other two open
windows. If you have four open windows, each window receives one-quarter of the
screen; the active window is placed in the upper-left corner. For more windows, you'll
have to experiment.
The Hide option removes the active window from the screen. You cannot redisplay a
system window (such as an edit window for a program) without reissuing the command
that created it. If you hide a user-defined window, however, that window remains in
memory; you can redisplay it with the SHOW WINDOW command. If you hide the current
output window, it continues to receive output even while it is hidden, which means that
you cannot see it. Upon redisplaying the window, you again see anything that has been
written to it.
The Clear option erases text from the current screen or active window. Notice that when
you use the SHOW WINDOW command after hiding a window, that window does not
automatically become the active window; its status depends on whether it was the active
window when it was hidden and whether you activated another window in the meantime.
(To ensure that a window is active, use the ACTIVATE WINDOW command.) Therefore, be
careful about what you clear.
The Help Menu Options: Help is the final menu pad of the System menu. Table 9 lists
the options available in this menu. The first two options present different ways to access
the help file to get information on commands, functions, or features. The third option lists
support options that are available from Microsoft. The last option opens the typical
copyright screen for the product; it adds additional functionality by providing system
information and allowing the user to run other applications from within FoxPro.
Sample Applications Describes the sample applications provided with Visual FoxPro.
Microsoft on the Opens a second menu with options to use your Web browser to go
Web to a variety of Visual FoxPro pages on the Web, the Microsoft
home page, and several other locations.
Technical Support Provides a list of available resources from Microsoft that offer
additional help. The list includes a section that answers common
questions.
About Microsoft Displays the copyright screen for the product, along with FoxPro
Visual whom it is licensed to, version date, resource filename, default
directory, and product ID. Additional features include the capability
to list system information and to run other programs.
The About Microsoft Visual FoxPro option displays an initial screen that contains the
standard copyright and license information. The screen includes a special bonus: the
System Info button. Click this button to display information about your system.
Key(s) Action
Ctrl+A To select all the current objects.
Ctrl+C To copy the current selection to the clipboard.
Ctrl+D To start a Visual FoxPro Program
Ctrl+G To move the cursor to the designated line in a text or in the command
window.
Ctrl+M To resume a program.
Ctrl+P To Print.
Ctrl+R To redo.
Ctrl+S To save the file.
Ctrl+V To paste the content of the clipboard at the current cursor position.
Ctrl+W To leave the current operation and to save any modification.
Ctrl+X To cut the selected object from its current location and to place it on the
clipboard.
Ctrl+Y To append new record.
Ctrl+Z To undo.
Ctrl+F1 To activate the next window open within Visual FoxPro.
Ctrl+F2 To display the command window.
Ctrl+F4 To close the current window.
Ctrl+F5 To restore the current window to its original size.
Ctrl+F7 To move the current window with the arrow key.
Ctrl+F8 To increase/decrease the size of the current window.
Ctrl+F9 To minimize the current window to an icon.
Ctrl+F10 To maximize the current window.
Esc To exit current editing without saving the modification.
Toolbar
The Toolbar appears below the menu bar and displays the icon. To access the toolbar
using the mouse, click on the icon you want to use.
New Opens the New File dialog box to create a new file.
Open Opens the Open File dialog box to open an existing file.
Save Saves changes made to the current file. By default, the button uses
the file's original filename, except for a new file that has no name,
in which case it prompts for a filename.
Print Preview Uses a preview window to show what Print would output.
Cut Cuts the current selected text or object and places it on the
Clipboard.
Copy Copies the current selected text or object and places it on the
Clipboard.
Paste Copies the current contents of the Clipboard and pastes it at the
current insertion point location.
Undo Undoes the last action or command, with some limitations. The
Undo button cannot undo a PACK command, for example.
Run Appears enabled if Visual FoxPro has an executable file open, such
as a screen or program.
Modify Form Switches the currently executing form back into designer mode.
Database Lists the names of all open databases in a drop-down list. The
current database appears in the text box. You can switch to a
different database by selecting it from the list.
Command Window Opens or pops the Command window back into view and makes it
the active window.
View Window Opens or pops the View window back into view and makes it the
active window.
The status bar appears at the bottom of Visual FoxPro's main screen if SET STATUS is ON.
The status bar itself has two main areas: the message area on the left and indicator boxes
on the right.
The message area is blank when no table is open in the current work area. When a table is
open, the message area displays the following:
• The table's name
• The table's database name (enclosed in parentheses, if appropriate)
• The current record number
• The total number of records in the table
The Designers use this area to display the position and size of objects.
Finally, the message area displays the current sharable status of the file or current record
using one of the following designations:
• Exclusive
• Record Unlocked
• Record Locked
• File Locked
Visual FoxPro also uses this portion of the status bar to display system messages that
concern issues such as its progress during reindexing. Forms also use this area to display
text messages associated with fields and controls, as well as position and size information
while you are in the Designers.
The right end of the status bar contains either three or four indicator boxes. The first box
on the left indicates the status of the Insert key. This box is blank when VFP's editor is in
Insert mode; otherwise, the letters OVR appear, indicating overwrite mode. The next box
displays NUM when the Num Lock key is on. The third box indicates the status of the
Caps
Zooming Windows
As mentioned earlier in this chapter, the title bar of a window has several buttons on the
right side. The button with the lower horizontal line minimizes the window, representing
it with an icon or docking it in the taskbar. (For windows within FoxPro, however, this
button docks the icon on FoxPro's main screen, not the Windows desktop.) The button
with the single window image maximizes the window. For a maximized window, the
Restore button replaces the Maximize button; it has the image of two cascaded windows.
If you do not have a mouse, or if you just prefer not to take your hands off of the
keyboard long enough to pick up the mouse, you can zoom the window by using shortcut
keys. You can open the Windows 95 Window menu by pressing Alt+-. This shortcut key
displays the options and their shortcut keys. Table 10 lists the shortcut keys, which work
consistently across all Windows applications.
Table 10: Commands in the Window Menu with Their Shortcut Keys
File Types The different types of files possible in Visual FoxPro are shown below.
Wizards: Wizards are interactive programs that help the user to create a new file (table,
report or query) by answering a series of questions. Different types of wizards available
in Visual FoxPro are shown in the following screen.
INTRODUCTION TO PROGRAMMING
Definition
In order to solve a computation problem, its solution must be specified in terms of a
sequence of computational steps, each of which may be effectively performed by a human
agent or by a digital computer.
Systematic notations for the specification of such sequences of computation steps are
referred to as programming languages.
The task of developing programs for the solution of computation problems is referred to
as programming.
Ideally, these steps are generally performed in sequence. But in practice, the development
goes through a spiral process.
1. Accuracy: The program must do what it is supposed to do, and meet the criteria laid
down in its specification.
2. Reliability: The program must ALWAYS do what it is supposed to do, and never
crash.
3. Efficiency: The program must use the available store space and resources in such a
way that the system's speed is not wasted.
4. Robustness: The program should cope with invalid data without stopping, with no
indication as to the cause and without creating errors.
6. Maintainability: The program must be easy to amend, having good structuring and
documentation.
7. Readability: The code in the program must be well laid out and explained with
comments.
Programming Language
The term programming language usually refers to high-level languages, such as BASIC,
C, C++, COBOL, FORTRAN, and Pascal. Each language has a unique set of keywords
(words that it understands) and a special syntax for organizing program instructions.
High-level programming languages, while simple compared to human languages, are
more complex than the languages the computer actually understands, called machine
languages. Each different type of CPU has its own unique machine language.
Lying between machine languages and high-level languages are languages called
assembly languages. Assembly languages are similar to machine languages, but they are
much easier to program in because they allow a programmer to substitute names for
numbers. Machine languages consist of numbers only.
Algorithm
Characteristics of Algorithms
The skilful choice of the algorithm for solving a problem, the rational sequence of
operations, and the methods of recording intermediate results assist in speeding up the
solution and reducing errors and time.
Flowchart
Report Generation
Commercial outputs need formatted output. These formatted outputs are known as
reports. A formatted report may have the following:
• Report heading
• Page heading
• Page numbering
• Footers
• Some remarks
• Date, month, and year of printing
Commercial outputs may also extend over multiple pages. In that case, one will have to
keep a provision in his program so that certain details get printed on every page.
• Page footer: It is printed at the bottom of each page. It generally totals number of
• Report detail: This constitutes the main body of a report. The output details or the
Example:
• Records of a particular region are grouped together and printed at one place.
• When the control break occurs, certain procedures are followed, such as looking at
• It may be necessary that performance of each region is printed on each page, that
is, when the control break occurs the report is printed on a fresh page.
• At the end of report it may be necessary to calculate and print the grand total.
Syntax:
MODIFY COMMAND <Program Filename>
Example:
MODIFY COMMAND NEW
Saving a Program
• Select FILE » SAVE AS
or
• Press Ctrl+W key combination
Executing a Program
A Visual FoxPro program is executed by using the command DO.
Syntax:
Do <Program Filename>
Example:
Do NEW
To stop a program
To stop a program in between, press ESC. It displays an alert that gives three choices.
• Cancel Stops execution of the program permanently. This is the default choice.
• Suspend Stops execution of the program temporarily and returns to the command
window.
Select PROGRAM»RESUME to start again from the point where you left.
Memory Variables
Memory variables are temporary quantities that are stored in the memory (RAM). They
are required in programs to store values which can be later used in calculations or to store
the results of calculation. A unique name, called the memory variable name, needs to be
assigned to each data item. It should be a maximum of 10 characters in length. The first
character of a memory variable must be a letter and spaces are not allowed. A memory
variable name can comprise letters, numerals, or underscore character (_). Declaring
Memory Variables Memory variables can be declared in any one of the two ways:
IA single STORE command can be used to declare more than one memory variable.
Example:
STORE "UPTEC12" TO NUM
OR
NUM = "UPT1"
Example:
STORE 55 TO N
OR
N = 532
• Date Contains dates that follow the Visual FoxPro's date format and are enclosed
in a pair of parentheses or ellipses.
Example:
STORE {03/18/97} TO DOJ
OR
DOJ ={03/18/97}
• Logical Stores either a logical T/F and should be enclosed by a pair of dots (.).
Example:
STORE .T. TO ANS
OR
ANS = T.
Example:
SAVE TO MEMFILE1
SAVE TO MEMFILE2 ALL LIKE A*
Example:
RELEASE ALL
CLEAR MEMORY
RELEASE ALL LIKE B *
Example:
COUNTRY = SPACE (15)
Notes
Normally used in programs to display a blank area (of a specified length) for data entry
by the user.
ACCEPT Command
Function: Displays a specified message (prompt) on the screen and accepts the data
entered through the keyboard in a character variable.
Example:
ACCEPT "Enter Employee Name:" TOEMPNAME
It stores the entered data in Empname variable. It automatically creates the variable
specified with ACCEPT.
INPUT Command
Function: Used to accept data entered through the keyboard in a character, numeric,
logical or date variable.
Example:
INPUT "Enter data:" TO CH
Different types of variables will be created depending upon the data entered.
WAIT Command
Function: Used to pause the execution of the program. The following message is
displayed when it encounters WAIT.
Press Any Key To Continue...
Example:
WAIT
WAIT "Press any key when printer is ready"
WAIT "Do you want to continue (Y/N):" TO ANS
Comment lines (or remark lines) can be included anywhere in the program. A comment
line begins on a new line and starts with * or NOTE. Comments are non-executable
statements.
EOF() determines whether or not the record pointer is positioned past the last record in
the current or specified table/.DBF or index file.
EOF() returns a logical true value (.T.) if the record pointer reaches the end of the file.
BOF() is determined if the record pointer is positioned at the beginning of a table/.DBF.
Returns true (.T.) if you try to move the record pointer to a position before the first logical
record in the Table/.DBF.
SKIP Command
Function: Moves the record pointer forward or backward in the current or specified
table/.DBF.
Example:
SKIP
SKIP-3
Loop Constructs
DO WHILE...ENDDO
LOOP Returns program control directly back to DO WHILE. LOOP can be placed
anywhere between DO WHILE and ENDDO.
EXIT Transfers program control from within the DO WHILE loop to the first command
following ENDDO. EXIT can be placed anywhere between DO WHILE and ENDDO.
Commands between DO WHILE and ENDDO are executed for as long as the logical
expression. Expression remains true (.T.). Each DO WHILE statement must have a
corresponding ENDDO statement.
Comments can be placed after DO WHILE and ENDDO on the same line. The comments
are ignored during program compilation and execution.
Example:
• Program to generate numbers from 1 to 100.
CLEAR
N=1
DO WHILE N<= 100
?N
N = N+1
ENDDO
FOR..ENDFOR Loop
Var Specifies a variable or an array element that acts as the counter. The variable or array
element does not have to exist before FOR...ENDFOR is executed.
Exit Transfers control from within the FOR.. .ENDFOR loop to the command
immediately following ENDFOR. You can place EXIT anywhere between FOR and
ENDFOR.
LOOP Returns control directly back to the FOR clause without executing the statements
between LOOP and ENDFOR. The counter is incremented or decremented as if
ENDFOR were reached. LOOP can be placed anywhere between FOR and ENDFOR.
Examples:
• To generate first 1000 Numbers
FOR N=l TO 10
?N
ENDFOR
SCAN...ENDSCAN Loop
Function: This loop is specifically used for processing table files. It automatically
terminates when it reaches the end of the file. The record pointer is automatically moved
to the next record in a SCAN...ENDSCAN loop, so SKIP command is not specified.
Syntax:
IF Expression [THEN]
Commands
[ELSE Commands]
ENDIF
Notes
• For every IF there must be an ENDIF.
ELSE Part is optional
• You can nest an IF...ENDIF block within another IF..ENDIF block.
Every ENDIF is matched with the nearest unmatched IF.
• Comments proceeded by && can be placed on the same line after IF, THEN,
ELSE, and ENDIF. These comments are ignored during compilation and program
execution.
Example:
The following program accepts an employee code from the user through ACCEPT
command and then using SEEK command finds the code in the employee table.
CLEAR
USE EMPLOYEE INDEX ECODE
ACCEPT "Enter Employee code" TO EC
SEEK EC
IF FOUND ( )
? "Employee code: " + EMPCODE
? "Employee Name:" + EMPNAME
?
ENDIF
CLOSE ALL
RETURN
Syntax:
DO CASE
CASE Expressionl
Commands
[CASE Expression2]
Commands
…………….
CASE ExpressionN
Commands
[OTHERWISE Commands]
ENDCASE
CASE Expression1 Commands When the first true (.T.) CASE expression is
encountered; the set of commands following it is executed. Execution of the set of
commands continues until the next CASE or ENDCASE is reached. Execution then
resumes with the first command following ENDCASE.
If a CASE expression is false (.F.), the set of commands following it up to the next CASE
clause is ignored. Only one set of commands is executed. These are the first commands
whose CASE expression evaluates to true (.T.). Any succeeding true (.T.) CASE
expressions are ignored.
OTHERWISE, the commands following OTHERWISE are executed and execution skips
to the first command following ENDCASE.
If you omit OTHERWISE, execution skips to the first command following ENDCASE.
Example:
CLEAR
N1=0
N2 = 0
T=0
INPUT "Enter first Number: " To N1
INPUT "Enter Second Number:" TO N2
CLEAR
? "Main Menu"
? " A. Addition"
? " B. Subtraction"
?"C. Multiply"
? "D. Divide"
? " E. Exit"
ACCEPT "Enter choice To UPPER (CH)
DO CASE
CASE CH = "A"
T = N1+N2
CASE CH="B"
IF N1>N2
T = N1-N2
ELSE
T=N2-N1
ENDIF
CASE CH="C"
T = N1*N2
CASE CH="D"
IF N1>N2
T = N2/N1
ELSE
T = N1/N2
ENDIF
CASE CH="E"
RETURN
OTHERWISE
? "Invalid Option..."
ENDCASE
? "Result is", T
RETURN
I IF ( ) S t a t e m e n t s
Function: Returns one of two values depending on the value of a logical expression.
Example:
?IIF(AGE>19, "Eligible to vote", "Not eligible to vote")
Example:
CLEAR
N=1
DO WHILE N<6
M=l
DO WHILE M < =N
??M
M = M+1
ENDDO
?
N = N+1
ENDDO
RETURN
Example of NESTED IF
CLEAR
?
INPUT "Enter any number between 1 and 4" TO NUM
?
IF NUM = 1
? "You entered one"
ELSE
IF NUM =2
? "You entered two"
ELSE
IF NUM =3
? "You entered three"
ELSE
IF NUM =4
? "You entered four"
ELSE
? "Error"
ENDIF
ENDIF
?
WAIT
Programming Macros
Example:
The @ Command
It is the most powerful and flexible command used for purposes such as:
• To place data at a particular screen location.
• To input data in fields or memory variables.
• To retrieve data.
• To input data through check boxes, radio buttons, push buttons, etc.
• To draw or clear boxes and lines.
<row, col>
Numeric expression. Row starts from 0-23 in FoxPro for DOS and from 0-35 in FoxPro
for Windows; and columns are numbered from 0 to 79, although results in FoxPro for
Windows might vary depending on your display.
<expr>
Specifies what is to be displayed. <expr> can include the expression that is to be
evaluated, displayed or printed starting at <row, col>.
& Command
Performs macro substitution.
Macro substitution statements that appear in DO WHILE, FOR, and SCAN are evaluated
only at the start of the loop and are not reevaluated on subsequent iterations. Any changes
to the variable or array element that occur within the loop are not recognized.
&& Command
Indicates the beginning of a non executing inline comment in a program file.
Inserting inline comments to denote the end of the IF ... ENDIF, DO, and FOR ...
ENDFOR structured programming commands greatly improves the readability of
programs when including many such structures.
* Command
Indicates the beginning of a non executing comment line in a program file.
= Command
Evaluates one or more expressions.
Specifies the expression or expressions that the = command evaluates.
The = command evaluates one or more expressions, Expression1, Expression2 ..., and
discards the return values. This option is particularly useful when a Visual FoxPro
function or a user-defined function has a desired effect, but there is no need to assign the
function's return value to a variable, array element, or field.
? | ?? Command
Evaluates expressions and sends the results to the main Visual FoxPro window, an active
user-defined window, or the printer.
? Expression1
Evaluates the expression specified by Expression1 and sends a carriage return and line
feed preceding the expression results.
?? Expression1
Evaluates the expression specified by Expression1 and displays the expression results on
the current line at the current position of the main Visual FoxPro window,
??? Command
Sends output directly to the printer.
\ | \\ Command
Prints or displays lines of text.
\ TextLine
When you use \, the text line is preceded by a carriage return and a line feed.
\\ TextLine
When you use \\, the text line is not preceded by a carriage return and a line feed.
APPEND Command
Adds one or more new records to the end of a table.
APPEND [BLANK]
Adds one blank record to the end of the current table. Visual FoxPro does not open an
editing window when you issue APPEND BLANK.
When you issue APPEND or APPEND BLANK and a table isn't open in the currently
selected work area, the Open dialog appears so that you can choose a table to which you
can append records.
APPEND opens an editing window so you can enter data into one or more new records.
When you add a new record, Visual FoxPro updates any indexes that are open.
ASSERT Command
Displays a message box when a logical expression evaluates to False (.F.).
When the condition stipulated in the ASSERT command evaluates to False (.F.), an assert
message box displays and echoes to the Debug Output window in the Debugger.
AVERAGE Command
Computes the arithmetic average of numeric expressions or fields.
AVERAGE [ExpressionList] [FOR lExpression1] [WHILElExpression2]
BLANK Command
Clears data from the specified fields in the current record or from all fields in the current
record when issued without additional arguments.
BLANK [FIELDS FieldList] [FOR lExpression1] [WHILE lExpression2]
Note
BLANK does not clear field data of a record in another related work area if the record
pointer is at the end of the file in the current work area. The record pointer must be on a
record in the current work area in order for BLANK to act on the fields in the related
record.
BROWSE Command
Opens the Browse window and displays records from the current or selected table.
CANCEL Command
Ends execution of the current Visual FoxPro program file.
Control returns to the Command window when Visual FoxPro is being used interactively.
If a distributed run-time application is running, CANCEL terminates the application and
control returns to Windows. If a program is executing in Visual FoxPro during design
time, CANCEL terminates the program and control returns to the Command window.
Executing CANCEL releases all private variables.
CLEAR Commands
Releases the specified item or items from memory.
CLEAR [ALL]
CLEAR erases the main Visual FoxPro window or the current user-defined window, and
releases from memory all pending @ ... GET controls. You can include CLEAR in format
files.
CLOSE Commands
Closes various file types.
CLOSE [ALL | ALTERNATE | DATABASES [ALL]
CONTINUE Command
Continues the previous LOCATE.
Remarks
CONTINUE is used after LOCATE succeeds in finding a record, to continue the
LOCATE operation. CONTINUE moves the record pointer to the next record for which
the logical expression specified in the previous LOCATE evaluates to True (.T.).
CONTINUE can be repeated until the end of the file is encountered, or until the end of
the scope you specified with LOCATE is reached.
If CONTINUE succeeds in finding a record, RECNO( ) returns the record number of the
record, FOUND( ) returns a value of True (.T.), and EOF( ) returns a value of False (.F.).
Remarks
COPY FILE creates a duplicate of the file whose name is specified in FileName1. You
can use COPY FILE to copy any type of file. The file to be copied cannot be open. You
must include the extensions for both the source file name FileName1 and destination file
name FileName2.
COPY TO Command
Creates a new file from the contents of the currently selected table.
COPY TO FileName [DATABASE DatabaseName]
COUNT Command
Counts table records.
COUNT [Scope] [FOR lExpression1] [WHILE lExpression2] [TO VarName]
COUNT counts the records within a scope of records for which the FOR or WHILE
conditions are true. If SET TALK is ON, the record count is displayed.
Records marked for deletion are included in the count if SET DELETE is OFF.
CREATE Command
Opens the Table Designer so you can create a Visual FoxPro table.
If a database is open when you create a table, the table is added automatically to the
database.
When running on the Windows operating system, you cannot create a table with the name
of an MS-DOS device, such as CON, NUL, PRN, and COM1. Avoid using hyphens in a
table name because hyphenated table names do not appear in the Data Session window
and can cause confusion with the alias pointer (->).
After opening the Table Designer, you need to define attributes for the fields in the table.
After you create the table structure, you can add records to the table. For more
information, see Creating Tables.
A database (.dbc) file is created with an associated database memo (.dct) file and database
index (.dcx) file.
The database opens exclusively, regardless of the setting of SET EXCLUSIVE. Because
CREATE DATABASE opens the database after it has been created, you do not need to
call a subsequent OPEN DATABASE command.
Using CREATE DATABASE does not add the database automatically to a project even
when the Project Manager is open. You must explicitly add a database to an application
project to include it.
Remarks
Issuing CREATE FORM without any additional arguments opens a new form in the Form
Designer. When you exit the Form Designer, you are prompted to save the form with a
different name.
Remarks
Issuing CREATE MENU without any additional arguments opens the Menu designer
within which you can define a menu system. The name MENU1 is temporarily assigned
to the menu definition table. When you exit the Menu designer, you can save the menu
definition under a different name.
A project is a table that keeps track of all files that are required to create an application, as
well as all dependencies, references, and connections among the files. A project table has
a .pjx extension and an associated memo file with a .pjt extension. In a project, you
specify all the pieces that are required for an application, and Visual FoxPro ensures that
compiled files are based on the latest source files.
A project table can be opened with USE and manipulated like any other Visual FoxPro
table.
Issuing the command CREATE PROJECT without any additional arguments displays the
Create dialog, allowing you to specify a name for the project.
CREATE QUERY opens the Query designer so you can interactively create a query.
After you create a query, the query is stored as a Visual FoxPro program file with a .qpr
extension. A query program can be executed with DO. You must include the query file
extension when executing a query with DO, as shown in the following example.
DO my_query.qpr
Issuing the command CREATE QUERY without any additional arguments opens a new
query window. The name QUERY1 is assigned to the query. When you exit the Query
window, you can save the query with a different name.
You can also create reports using a wizard. You can also create quick reports without
opening the Report Designer using another version of CREATE REPORT.
More than one user-defined window can be placed in the main Visual FoxPro window at
the same time, but output is directed only to the most recently activated user-defined
window. When more than one user-defined window is present, deactivating the current
user-defined output window clears the contents of the window, removes the window from
the screen and sends subsequent output to the previously activated user-defined window.
If there is no output window, output is directed to the main Visual FoxPro window.
Use CLEAR WINDOWS or RELEASE WINDOWS to remove windows from both the
screen and memory.
To deactivate a system window and or a toolbar (in Visual FoxPro), enclose the entire
system window or toolbar name in quotation marks. For example, to deactivate the
Report Controls toolbar in Visual FoxPro, issue the following command:
DEACTIVATE WINDOW "Report Controls"
DECLARE Command
Creates a one- or two-dimensional array.
You can use either brackets or parentheses to enclose the expressions in DECLARE.
DEBUG Command
Opens the Visual FoxPro debugger.
The debugger Environment setting (FoxPro Frame or Debugger Frame) determines if the
debugger is placed on the Visual FoxPro desktop or in a separate window. Toggle this
setting in the Debugging tab of the Options dialog box.
If you issue DEBUG when the debugger is open, the debugger becomes the active
window.
After user-defined windows are created with DEFINE WINDOW, they can be displayed
in the main Visual FoxPro window with ACTIVATE WINDOW or SHOW WINDOW.
The number of user-defined windows you can create is limited only by the amount of
available memory and system resources.
Activated windows remain in the main Visual FoxPro window until DEACTIVATE
WINDOW or HIDE WINDOW is issued. DEACTIVATE WINDOW and HIDE
WINDOW remove windows from the main Visual FoxPro window but don't remove the
window definitions from memory. Windows can be placed back in the main Visual
FoxPro window with ACTIVATE WINDOW or SHOW WINDOW.
Use CLEAR WINDOWS or RELEASE WINDOWS to remove windows from the main
Visual FoxPro window and window definitions from memory. Windows whose
definitions have been removed from memory must be recreated with DEFINE WINDOW
in order to be redisplayed.
DELETE Command
Marks records for deletion.
Records marked for deletion aren't physically removed from the table until PACK is
issued. Records marked for deletion can be recalled (unmarked) with RECALL.
Always use DELETE DATABASE to delete a database from disk. Unlike the file
manipulation utility of the operating system, DELETE DATABASE removes references
to the database from the tables in the database.
If SET SAFETY is ON, Visual FoxPro asks if you'd like to delete the database you
specify. If SET SAFETY is OFF, the database is automatically deleted from disk.
The file you want to delete cannot be open when DELETE FILE is issued. The file name
must include a path if it is on a different drive or volume, or in a different directory from
the default. A file name extension must be included.
If the file you want to delete represents a table that is part of a database, you need to
remove the table from the database before deleting the file. You can use the REMOVE
TABLE command before using the DELETE FILE command. If you delete a table that
has an associated .FPT memo file, be sure to delete the memo file.
This command does not generate an error if the specified file does not exist.
The DELETE FILE command is the same as the ERASE command.
The file you want to delete cannot be open when DELETE FILE is issued. The file name
must include a path if it is on a different drive or volume, or in a different directory from
the default. A file name extension must be included.
DISPLAY Command
Displays record contents and expression results for the current table in the main Visual
FoxPro window or a user-defined window.
DISPLAY [FIELDS][FOR lExpression1] [WHILE lExpression2]
DISPLAY is similar to the LIST command except that DISPLAY displays information
one screen at a time and pauses between screens. LIST displays the same information
without pausing. To view the next screen, press any key or click anywhere in the Visual
FoxPro window.
Use DISPLAY FILES to display information about files residing on a disk. You can
display information about all files on a specified drive, volume, directory, or folder.
Issuing DISPLAY FILES without any arguments displays information about tables in the
current directory. The information displayed includes the following:
• Table name.
• Number of records in the table.
• Date and time of the last update to the table.
• The size of each table in bytes.
• If each table is part of a database.
• The number of decimal places in the field if the field has Numeric, Double, or
Float type.
• If the field is an auto incrementing field, the Next and Step values in the last two
columns.
• The current number of records in the table and the date it was last updated.
• The memo field blocks size if the table has an associated memo field.
• If the table is associated with a structural compound index, and if a tag, or index
entry, in the structural compound index has the same name as a field in the table,
DISPLAY STRUCTURE displays the order of the tag, ascending or descending, and the
DO CASE
CASE lExpression1
[Commands]
[CASE lExpression2
[Commands]]
...
[CASE lExpressionN
[Commands]]
[OTHERWISE
[Commands]]
ENDCASE
DO CASE is used to execute a set of Visual FoxPro commands based on the value of a
logical expression. When DO CASE is executed, successive logical expressions are
evaluated; the values of the expressions determine which set of commands is executed.
Comments can be placed after DO CASE and ENDCASE on the same line. The
comments are ignored during program compilation and execution.
DO Command
Executes a Visual FoxPro program or procedure.
When you use DO to run a program, the commands contained in the program file are
executed until one of the following occurs:
• RETURN is encountered.
• CANCEL is executed.
• Another DO is issued.
• The end of the file is reached.
• QUIT is executed.
If you choose Do from the Program menu and execute a program in a directory on a drive
other than the current directory or drive, Visual FoxPro automatically changes the default
directory and drive to the directory and drive containing the program.
DO FORM Command
Runs a compiled form or form set created with the Form Designer.
DO FORM FormName
DO FORM executes the Show method for the form or form set.
DO WHILE Expression1
Commands
[LOOP]
[EXIT]
ENDDO
Commands between DO WHILE and ENDDO are executed for as long as the logical
expression Expression1 remains true (.T.). Each DO WHILE statement must have a
corresponding ENDDO statement.
Comments can be placed after DO WHILE and ENDDO on the same line. The comments
are ignored during program compilation and execution.
When DROP TABLE is issued, all primary indexes, default values, and validation rules
associated with the table are also removed. DROP TABLE also affects other tables in the
current database if those tables have rules or relations associated with the table being
removed. The rules and relations are no longer valid when the table is removed from the
database.
EDIT Command
Displays fields for editing.
EDIT allows you to edit the selected table within a window. EDIT behaves identically to
CHANGE.
If you press ESC to exit the Edit window, changes made to the last field you modified are
discarded. However, if you move to another record after modifying a field, your changes
to the field are saved.
ERASE Command
Deletes a file from disk.
This command does not generate an error if the specified file does not exist.
The DELETE FILE command is the same as the ERASE command.
EXIT Command
Exits a DO WHILE, FOR, SCAN, or TRY…CATCH…FINALLY structure.
The EXIT command transfers control from within the structure to the command
immediately following the structure.
The Visual FoxPro commands that appear in the FOR loop execute until ENDFOR or
NEXT is reached. The value in the counter VarName then increments or decrements by
the value of nIncrement. The value of the counter is then compared with nFinalValue. If
the counter is less than or equal to nFinalValue, the commands following the FOR clause
execute again. If the counter is greater than nFinalValue, the FOR ... ENDFOR loop exits,
and program execution continues with the first command following ENDFOR or NEXT.
GATHER Command
Replaces the data in the current record of the currently selected table with data from an
array, a set of variables, or an object.
GATHER FROM ArrayName
GOTO Command
Moves the record pointer to the specified record number. There are multiple versions of
the syntax.
GO [RECORD] nRecordNumber
GO TOP | BOTTOM
GOTO [RECORD] nRecordNumber
You can use GO and GOTO interchangeably. These commands operate on the table in the
current work area unless you specify another work area with the IN clause.
If you use the nRecordNumber argument with GOTO and the specified physical record
does not exist in the table, the system will throw a "Record is out of range" error. The
record pointer will not move.
HIDE WINDOW removes a window or a set of windows from the main Visual FoxPro
window or from a user-defined window. You can use HIDE WINDOW to hide system
windows, such as the Command window, the Data Session window, and so on.
Hiding a window isn't the same as closing it. When a window is hidden, it stays resident
in memory and remains active. Output can be sent to a hidden window, but you cannot
see it.
Releasing a window removes it from memory. Windows removed from memory must be
defined again to be redisplayed. A window can be displayed with ACTIVATE WINDOW
or SHOW WINDOW.
IF Expression [THEN]
Commands
[ELSE
Commands]
ENDIF
You can nest an IF ... ENDIF block within another IF ... ENDIF block.
Comments proceeded by && can be placed on the same line after IF, THEN, ELSE, and
ENDIF. These comments are ignored during compilation and program execution.
IMPORT Command
Imports data from an external file format to create a new Visual FoxPro table.
Most software packages store their data in file formats that cannot be opened directly in
Visual FoxPro. IMPORT creates a new Visual FoxPro table from data stored in file
formats that Visual FoxPro cannot directly read.
A new table is created with the same name as the file from which the data is imported. A
.dbf extension is assigned to the newly created table.
INDEX Command
Creates an index file containing one or more indexes for displaying and accessing table
records in a specified order.
A structural .cdx file can become dissociated from its table if the index file cannot be
located, is deleted, or renamed. When you open a table that has a dissociated structural
.cdx file, a dialog box appears. When you click Cancel in the dialog box, the table does
not open.
LABEL Command
Sends labels from a label file (.lbx) to the specified output.
You can create label files using the CREATE LABEL Command or MODIFY LABEL
Command.
When you use Visual FoxPro's object-assisted output mode, all the clauses of the LABEL
FORM command are available to your ReportListener in its CommandClauses member
object, with the exception of record selection clauses (scope, FOR, and WHILE). You can
use the CommandClauses. RecordTotal attribute for information about the scope of the
label run, or assign these values to your ReportListener object before running your labels.
LIST Commands
Displays table or environment information without pausing the main Visual FoxPro or
user-defined window. There are multiple versions of the syntax.
LIST STRUCTURE
Remarks
The LIST commands are identical to the DISPLAY commands except for the following
differences:
* LIST displays information without pausing, whereas DISPLAY displays the first
screen of information and then pauses. For more information, see DISPLAY Command.
LOCATE Command
Sequentially searches the table for the first record that matches the specified logical
expression.
LOCATE [FOR lExpression1] [WHILE lExpression2]
If LOCATE finds a matching record, you can use RECNO( ) to return the number of the
matching record. If a matching record is found, FOUND( ) returns true (.T.), and EOF( )
returns false (.F.).
After LOCATE finds a matching record, you can issue CONTINUE to search the
remainder of the table for additional matching records. When CONTINUE is executed,
the search process resumes, starting with the record immediately following the matching
record. You can issue CONTINUE repeatedly until the end of the scope or the end of the
table is reached.
If a match isn't found, RECNO( ) returns the number of records in the table plus 1,
FOUND( ) returns false (.F.), and EOF( ) returns true (.T.).
LOCATE and CONTINUE are specific to the current work area. If another work area is
selected, the original search process can be continued when the original work area is
reselected.
LOOP Command
You can place LOOP anywhere between DO WHILE and ENDDO, anywhere between
FOR and ENDFOR or FOR EACH and ENDFOR, or anywhere between SCAN and
ENDSCAN.
The LOOP command returns control directly to the DO WHILE, FOR, or FOR EACH
clause without executing the statements between LOOP and ENDDO or ENDFOR. The
counter is incremented or decremented as if the END... statement were reached.
You can edit labels using the Visual FoxPro user interface.
A database must be open before you can create or modify stored procedures.
When modifications are made to a text file, the updated file is written to disk. In Visual
FoxPro, a backup file with a .bak extension is created if you select the Make Backup
Copy check box on the Edit Properties dialog box, which appears when you choose
Properties from the Edit menu. In previous versions of FoxPro, a backup file with a .bak
extension is created if you select the Backup check box in the Preferences dialog box,
which appears when you choose Preferences from the Edit menu.
In a project, you specify all the source files that are required for a final application, and
then Visual FoxPro makes sure the generated application is based on the latest source
files.
A project file is a table that keeps track of all the source files such as programs, forms,
menus, libraries, reports, labels, tables, indexes, and format files. A project also keeps
track of all the dependencies, references, and connections among the files.
Issuing MODIFY QUERY without any arguments displays the Open dialog box. If you
choose New from this dialog box, the name QUERY1 is assigned to the query. You can
save the query with a different name when you exit the Query Designer.
After you have created a query, the query is stored as a Visual FoxPro program file with a
.qpr extension. You can execute a query program with DO, but you must include the .qpr
extension with the query file name.
Remarks
In previous versions of FoxPro, MODIFY STRUCTURE opens the Table Structure
dialog box.
If a table isn't open in the currently selected work area, the Open dialog box is displayed,
making it possible for you to choose a table to modify. Changes you can make to a table's
structure include adding and deleting fields; modifying field names, sizes, and data types;
adding, deleting, or modifying index tags; and specifying null value support for fields.
Use MODIFY WINDOW to change the location, default font, title, border, controls, icon,
wallpaper, and color of a user-defined window or the main Visual FoxPro window. You
can change any of these attributes by including the optional clauses for the MODIFY
WINDOW command. (Note that if you change colors, you must use CLEAR to apply the
color changes.)
PACK Command
Permanently removes all records marked for deletion in the current table and reduces the
size of the table memo (.fpt) file associated with the table.
You must first open the table exclusively before using the PACK command.
When you use PACK, Microsoft Visual FoxPro copies all records not marked for deletion
to a temporary table. After PACK is finished executing, Visual FoxPro deletes the
original table from disk and renames the temporary table with the original table name. If
you press the ESC key to cancel PACK, the temporary table is deleted, and the original
table remains unchanged. The original table is also recovered if you run out of disk space
while PACK is executing.
When you issue PACK without the MEMO and DBF clauses, PACK affects both the
table and the memo file.
PACK requires exclusive use of the table. For more information about opening a table
exclusively on a network, see SET EXCLUSIVE Command.
ON ERROR Command
Specifies a valid expression or Visual FoxPro command to execute when an error occurs
in code at run time.
If the error-handling procedure includes the RETRY command, the program executes the
line that caused the error instead of continuing on the immediate following line. For more
information, see RETRY Command.
You cannot nest ON ERROR commands;
PROCEDURE Command
Creates a user-defined procedure in a program file. There are two versions of the syntax.
PROCEDURE ProcedureName
Commands
RETURN
[ENDPROC]
When you issue the DO command with a procedure name, Visual FoxPro searches for the
procedure in the following order:
Visual FoxPro searches program files in order from the most recently executed
If a matching program file is found, Visual FoxPro executes the program. Otherwise,
Visual FoxPro generates an error message.
QUIT Command
Ends the current Visual FoxPro session and returns control to the operating system.
Always use QUIT to terminate a Visual FoxPro session. If you turn the computer off
without issuing QUIT, open files might become damaged and data lost, and temporary
work files that would normally be deleted may be left on disk.
RECALL Command
Unmarks records marked for deletion in the selected table.
RECALL [FOR lExpression1] [WHILE lExpression2]
You can use RECALL to recover records, provided you have not issued PACK or ZAP.
You can mark records for deletion by issuing DELETE or DELETE – SQL, or by
choosing Delete Records from the Table menu when a Browse or Edit window is active.
You can recall records by issuing RECALL, or by choosing Recall Records from the
Record menu when a Browse or Edit window is active.
The following list includes system windows that can be released from the main Visual
FoxPro window or from a parent window.
* Command
* Data Session (use RELEASE WINDOW "View")
* Debug
* Debug Output
* Document View
* Locals
* Trace
* Watch
* View
Procedure files are opened with SET PROCEDURE. Once the file is open, the procedures
within the file are available to programs and from the Command window.
To close all open procedure files, issue SET PROCEDURE TO without any additional
arguments.
RELEASE Command
Removes variables and arrays from memory. There are several versions of the syntax.
RELEASE ALL
You cannot use RENAME TABLE to change the name of a free table; use RENAME
instead.
REINDEX Command
Rebuilds open index files.
REINDEX updates all index files open in the selected work area.
Index files become outdated when you open a table without opening its corresponding
index files and make changes to the index files' key fields. When index files become
outdated, you can update them by reindexing.
Visual FoxPro recognizes each index file type: compound index (.cdx) files, structural
.cdx files, and single index (.idx) files), and reindexes them accordingly. It updates all
tags in .cdx files and updates structural .cdx files, which automatically open with the
table.
RENAME Command
Changes the name of a file to a new name.
Note
Do not use RENAME to change the name of a table in a database; RENAME does not
change the name of the table in the database. Instead, use RENAME TABLE to change
the name of a table in a database.
RENAME FileName1 TO FileName2
REPLACE Command
Updates table records.
REPLACE FieldName1 WITH Expression1 [, FieldName2 WITH eExpression2] ... [FOR
lExpression1] [WHILE Expression2]
REPLACE replaces data in a field with the value in an expression. Fields in unselected
work areas must be prefaced with their alias.
The REPORT FORM command can interpret Visual FoxPro label files (lbx format) as
well as report files. You can also use REPORT FORM to run character-based report files
created in FoxPro for MS-DOS.
RESTORE FROM Command
Retrieves variables and variable arrays saved in a variable file or a memo field and places
them into memory.
RESTORE FROM FileName
RESUME Command
Continues execution of a suspended program.
Use SUSPEND to suspend program execution. The suspended program restarts at the line
where execution was suspended.
SUSPEND and RESUME are valuable debugging tools. You can suspend a program to
examine the current status of the Visual FoxPro environment, including memory
variables, window, menu bar, or menu definitions.
RETURN Command
Returns program control to a calling program.
RETURN terminates execution of a program, procedure, or function and returns control
to the calling program, the highest-level calling program, another program, or the
Command window.
RETRY Command
Executes the last command from the memory stack and then returns control to the calling
program. RETRY is similar to RETURN, except RETURN executes the next line in the
calling program.
Use SAVE WINDOW to store window definitions in a window file or in a memo field.
Any windows in memory with the same names as those restored are overwritten. A
window's status (hidden, active, and so on) when it is saved is preserved when it is
restored.
RUN | ! Command
Executes external operating commands or programs.
RUN [/N] WindowsCommand | ProgramName
You can issue RUN from within the Command window or from within a program.
Use RESTORE SCREEN to redisplay images saved to the screen buffer, a variable, or an
array element.
SAVE TO Command
Stores current variables and arrays to a variable file or memo field.
To place variables and arrays back into memory from a variable file or memo field, use
the RESTORE FROM command.
SCAN automatically advances the record pointer to the next record that meets the
specified conditions and executes the block of commands.
You can place comments after ENDSCAN on the same line. The comments are ignored
during program compilation and execution.
SCAN ... ENDSCAN ensures that, upon reaching ENDSCAN, Visual FoxPro reselects
the table that was current when the SCAN ... ENDSCAN loop began.
SCATTER Command
Copies data from the current record to a set of variables, to an array, or an object.
SCATTER and COPY TO ARRAY behave similarly. SCATTER copies only a single and
current record into an array or a set of variables and automatically creates the array or
variables if they do not already exist. COPY TO ARRAY copies multiple records into an
array. To copy variables or array elements to table records, use the GATHER Command.
SEEK Command
Searches a table for the first occurrence of a record whose index key matches a general
expression, then moves the record pointer to the matching record.
You can use SEEK only with indexed tables, and you can search only on the index key.
The match must be exact unless SET EXACT is set to OFF.
If SEEK finds a record with a matching index key, RECNO( ) returns the record number
of the matching record, FOUND( ) returns true (.T.), and EOF( ) returns false (.F.).
If a matching key isn't found, RECNO( ) returns the number of records in the table plus 1,
FOUND( ) returns false (.F.), and EOF( ) returns true (.T.).
The SET command performs different operations when used with various keywords.
SET [ [SetCommand] [ON | OFF]
When no arguments are passed, SET opens the Data Session window. The Data Session
window provides an easy way to open tables, establish relations, or change different
Microsoft Visual FoxPro settings.
SKIP Command
Moves the record pointer forward or backward in a table.
SKIP [nRecords]
If the table has a master controlling index tag or index file, SKIP moves the record
pointer to the record determined by the index sequence.
SORT Command
Sorts records in the currently selected table and outputs the sorted records to a new table.
SORT TO TableName ON FieldName1 [ASCENDING | DESCENDING]
[FOR lExpression1] [WHILE lExpression2]
One or more specified fields in the current table determine the order in which the records
appear in the new table.
Character-type fields that contain numbers and spaces might not sort in the order you
expect. Numeric fields fill from right to left, with empty spaces to the left. In contrast,
character fields fill from left to right, with empty spaces to the right.
For example, if two records in a table contain a character field with 1724 in one record
and 18 in the other, and the table is sorted on this field in ascending order, the record
containing 1724 appears before the record containing 18. This is because Visual FoxPro
reads each character in the character fields from left to right, and because 17 (in 1724) is
less than 18 (in 18), it puts 1724 first. To avoid this problem, always precede lower
numbers with leading zeros (0018) or make the field numeric.
STORE Command
Stores data to a variable, to an array, or to an array element.
SUM Command
Totals all or specified numeric fields in the currently selected table.
SUM [ExpressionList] [FOR lExpression1] [WHILE lExpression2]
SUSPEND Command
Pauses program execution and returns to interactive Visual FoxPro.
While a program is paused, you can execute intervening commands, check variable
values, open the Trace and Debug windows, and so on.
The current output device can include the main Visual FoxPro window, a user-defined
window, a printer, a text file, or a low-level file.
By default, TEXT ... ENDTEXT sends output to the main Visual FoxPro window or the
active window. To suppress output to the main Visual FoxPro window or the active
window, issue SET CONSOLE OFF. To send output to a printer or a text file, use SET
PRINTER.
TOTAL Command
Computes totals for numeric fields in the currently selected table.
TOTAL TO TableName ON FieldName [FOR lExpression1] [WHILE lExpression2]
The table in the currently selected work area must be sorted or indexed. A separate total is
calculated for each set of records with a common field value or unique index key value.
The results are placed into records in a second table. One record is created in the second
table for each common field value or unique index key value.
Numeric overflow can occur if the numeric fields in the second table are not wide enough
to contain the totals. Visual FoxPro conserves the most significant portions of the totals
when numeric overflow occurs. When a field is too small to accept a total:
* Decimal places are truncated, and the remaining decimal portion of the total is
rounded.
* If the total still does not fit, scientific notation is used if the total field contains seven
or more digits.
* Finally, asterisks replace the field contents.
TYPE Command
When SET HEADINGS is ON, Visual FoxPro inserts a form feed, the path and name of
the file, and the date at the beginning of output produced with TYPE. If SET HEADINGS
is OFF, this information isn't included.
In FoxPro for MS-DOS, if a printer driver setup is loaded and you direct output from
TYPE to a file or a printer, TYPE displays the file contents using the settings from the
printer driver setup.
UNLOCK Command
Releases a record lock, multiple record locks, or a file lock from a table, or releases all
record and file locks from all open tables.
UNLOCK [RECORD nRecordNumber] [ALL]
Record and file locks can be removed from a table only by the user who issued the locks.
UNLOCK cannot unlock a table opened for exclusive use.
A record lock (or locks) or a file lock is released from the table in the current work area if
you issue UNLOCK without any additional arguments.
USE Command
Opens a table and its associated index files or opens a SQL view.
USE [DatabaseName] TableName
If you issue USE without a table name, and a table file is open in the currently selected
work area, Visual FoxPro closes the table. Visual FoxPro also closes a table when another
table is opened in the same work area. You cannot have more than one table open in a
work area at one time.
When used with a non current database, the USE command opens the database
automatically but does not set the database as the current database. When the table closes,
the database remains open.
WAIT Command
Displays a message and pauses Visual FoxPro execution until the user presses a key or
clicks the mouse.
WAIT [MessageText] [TIMEOUT nSeconds]
If a WAIT message is displayed in Visual FoxPro for Windows, pressing the SHIFT or
CTRL keys hides all windows including the WAIT message.
WITH ... ENDWITH provides a convenient way to specify a number of properties for a
single object. Note that you can also execute methods from within a WITH ... ENDWITH
structure.
ZAP Command
Removes all records from a table, leaving just the table structure.
Issuing ZAP is equivalent to issuing DELETE ALL followed by PACK, but ZAP is much
faster.
If SET SAFETY is ON, Microsoft Visual FoxPro asks if you would like to remove the
records from the current table.
♦ Using Menu System Select File » New, a New dialog box will appear as shown
below:
As soon as the above operation is performed, the Table Designer dialog box appears on
the screen.
Field Name
When naming a field, use a name that best describes the contents of the field.
• Field name must be unique, and must begin with an alphabet.
• Field name may have up to ten characters including letters from A to Z, whole
numbers, and the underscore character and must not contain spaces.
For example,
Emp-Phone is an invalid field name because of the presence of hyphen sign.
Emp_Phone is valid field name.
"Type" means the type of data that can be stored in the corresponding field. Visual
FoxPro allows 13 types of data to be stored in the fields. These are:
Character Type In this type of field, you can store any alphanumeric data. Numeric data
can also be stored in this type of field, but no numeric calculation can be done. A
maximum of 254 characters can be stored in a character-type field. To store this type of
data it needs 1 byte of data storage space for each character.
Currency Type This type of field is used to store monetary values. A maximum of 20
digits can be stored here including"+","-" and"." (Decimal point). To store this type of
data it needs 8 bytes of memory space.
Numeric Type Any numeric data can be stored in this type of field. A maximum of 20
digits can be stored here"+","-", and"." (Decimal point). It requires 8 bytes of memory
space to store this type of data.
Float Type This type of field is mainly required to store scientific data. A maximum of
20 digits including"+","-", and".") can be stored in this type of field. Eight bytes of
memory space is required to store this type of data.
Integer Type It can store only integer value. It needs 4 bytes of memory space to store
the data.
Date Type This type of field is used to store any type of date value. Default format for
storing date is "mm/dd/yy". The calculations related to date can be performed using this
type of field. Its acceptable range is from 01/01/100 to 12/31/9999. It requires 8 bytes of
memory space to store the data.
Date Time Type In this type of field, date and time are stored simultaneously using a
default format "dd/min/yy/hh/mm/ss". Accepted range of date is from 01/01/100 to
12/31/9999, and acceptable range of time is 00:00:00 am to 11:59:59 pm. Eight bytes are
required to store this type of data.
Double Type This is also a type of numeric field but with double precision. Eight bytes of
memory space is required to store the data.
Logical Type In this type of field we can only store "True" and "False" value in the form
of "T" and "F". One byte of memory space is required to store the data.
Memo Type In this field, we can store any type of data having any volume. The amount
of data which can be stored in this type of field can be determined only by the available
size of memory. Default width of emp field is 4. The data stored in memo field is stored
in a separate file with same name as the table but has an extension .FPT.
General Type In this field, you can store any picture, graph and other types of data using
an OLE object. In the table structure it shows only 4 bytes but the data can be of any size
and is stored in a separate file.
Character (Binary) In this field, you can store any picture, graph and other types of data
using an OLE object. In the table structure it shows only 4 bytes but the data can be of
any size and is stored in a separate file.
Memo (Binary) Memo-field data you want to maintain can be stored in this type of field
without any change across code pages. It shows 4 bytes in table-structure dialog box but
any amount of data can be stored here because it is stored in a separate file and is only
dependent on the available memory.
To create a new table using Table Wizard, follow the steps given below:
• Select File » New from the menu bar.
or
• Click at'New' icon on the Standard Toolbar.
or
• Press Ctrl+N.
On performing any of the above mentioned operations, a New dialog box appears on the
screen. Select Table from the "New" dialog box. And, then select "Wizard". Immediately
a Table Wizard dialog box appears. Table Wizard consists of a total of four steps.
Step One — Select Fields In the first step of Table Wizard, user is required to design the
table structure. Screen for Step-1 of Table Wizard is shown below:
In the dialog box given above, select the type of table you want to create from Sample
Tables list box. And, then move the list of required fields from Available Fields list box
to Selected Fields.
Step 4 — Finish
This is the last step of Table Wizard. Here, you are provided with three options:
• Save Table for later use.
• Save Table and browse it.
• Save Table and modify it in the Table Designer.
Select the appropriate option.
After saving the file, a dialog box appears asking about additions to the table. If you want
to add records to the table, select Yes otherwise select No.
Closing a Table
Normally, only one database file can be in use at a time. More than one table can be
opened using the SELECT command.
If another table is opened, the current file will no longer be in use, that is, current file is
automatically closed.
Opening a Table
To open an existing table, choose either of the following methods:
Enter USE <filename> in the Command window.
or
Choose File » Open.
List
Displays the contents of all or selected records on the screen, prints or stores it in a disk
file from the currently selected table.
Syntax
LIST [FIELDS field list] [FOR <expl1>] [While <exp12>
Arguments
REST Specify all the records beginning with current record and ending
Record<n> Specify the record number of the record <n> on which command
will act.
FIELDS field list By default, all fields from the table are displayed. Field list
While <expl2> the logical condition <expll> are displayed. If WHILE clause is
<expl2> evaluates to T.
For example:
Display
Displays a record from the current table.
Syntax
DISPLAY [scope] [FIELDS <fieldlist>] [FOR<expLl>] [WHILE <expL2>]
Example:
• DISPLAY
• DISPLAY NEXT 5 FOR DEPT = "COMPUTER"
• DISPLAY FIELDS EMPNAME, BASIC
• DISPLAY ALL
Note
• The main difference between LIST and DISPLAY is that, LIST command
displays all records by default whereas the default scope of DISPLAY is the
current record (Next 1).
• The similarity between the two occurs when DISPLAY is used with ALL option.
But again, LIST scrolls information continuously, whereas DISPLAY ALL pauses
whenever the screen becomes full.
FoxPro pointer is always pointing to some record whenever a table is in use. To move a
pointer to a specific record, GO/GOTO command can be used.
Syntax
GO /GOTO <TOP> <BOTTOM>
or
GO/GOTO[RECORD] <expn>
Arguments
TOP Pointer will be at the first record in the file.
B OTTOM Pointer will be at the last record in the file.
RECORD <expn> To move the pointer to the desired record number <expn>.
Examples:
GOTO 4 moves the record pointer to the 4th record of current table.
GO BOTTOM moves record pointer to the last record of current table.
Browse
Opens the Browse window and displays records from current or selected table.
Syntax
BROWSE [FIELDS Fieldlist]
[FONT cFontname [, n Fontsize]]
[STYLE cfont-style]
[FOR expl [REST]]
[FORMAT] [FREEZE fieldname]
[Key eLow [, eHigh]]
[LOCK n number of fields]
[NAMEObjectname]
[NOAPPEND] [NODELETE]
[NOEDIT INOMODIFY] [NOMENU] [NOWAIT]
Arguments
FOR expll
Specifies a condition whereby only records for which logical expression expl 1 is True
are displayed in BROWSE window.
REST
Prevents record pointer from being moved from its current position to the top of the table
when BROWSE window is opened with FOR clause. Otherwise, Browse positions the
record pointer at the top of the table by default.
FORMAT
Specifies use of a format file to control the display and data-entry format in a Browse
window. Format file must be opened with SET FORMAT. Format file can include the
following:
Append
Adds one or more new records to the end of a table.
Syntax
Append [BLANK] [IN nWORKAREA IcAlias] [No MENU]
Arguments:
Blank
Adds one blank record to the end of the current table. Visual FoxPro does not open an
editing window when you issue Append Blank. You can edit the new record with Edit,
Change, or Browse.
IN nWorkArea
Specifies the work area of the table to which a new record is appended.
Append From
Adds records to the end of the currently selected table from another file.
Syntax
APPEND FROM FILENAME [FIELDS fieldlist] [FOR expl]
Arguments:
• Filename
Specifies the name of the file to append from. Visual FoxPro assumes a default extension
.dbf when no extension is mentioned with filename.
• ?
Displays Open dialog box, from which you can choose a table to append from.
For example:
APPEND FROM EMP FOR SAL > 1000
Deleting Records
There are three commands to delete unwanted records from the table permanently or
temporarily. Delete, Pack, and Zap
Delete
Marks records for deletion. Records marked for deletion are not physically removed from
the table until PACK is issued.
Syntax
DELETE [Scope] [FOR<expll>] [WHILE <expl2>]
Arguments:
♦ Scope
Scope clause can include ALL, NEXT <n>, REST, RECORD <n>. Default scope of
DELETE is NEXT1.
For example:
DELETE NEXT 5
DELETE FOR ROLL > 200
Notes
• Browse, Edit or Change can also be used for deletion purpose.
• A function DELETED() is used to return logical value that indicates whether
current record is marked for deletion.
For example:
LIST FOR DELETED()
Pack
Permanently removes all records marked for deletion in current table and reduces size of
a memo file associated with the table.
Syntax
PACK [MEMO] [DBF]
Arguments:
♦ Memo
Removes unused space from memo file but does not remove records marked for deletion
from the table.
♦ DBF
Removes records marked for deletion from the table but does not affect the memo file.
When PACK command is issued, Visual FoxPro copies all records not marked for
deletion to a temporary table. After PACK has finished executing, Visual FoxPro deletes
the original table from disk and renames the temporary table with original table's name. If
Esc is pressed in between, then PACK is interrupted and temporary table is deleted
leaving original table unaffected. Original table is also recovered if you run out of disk
space while PACK is executing. When PACK is issued without any argument
(MEMO/DBF), PACK affects both the table and memo file. PACK requires exclusive use
of table. If current table has one or more indexes open, PACK rebuilds the index file. Be
careful to mark only those records that are of no use. There is no way to retrieve deleted
records after using PACK.
Zap
Removes all records from a table, leaving just the table structure intact. This command is
equivalent to DELETE ALL followed by PACK.
Syntax
ZAP [IN nWorkArea / cAlias]
If you omit nWorkArea and cAlias, all records are removed from the table in current
selected work area. Records zapped from the current table cannot be recalled.
Recall
Unmarked records marked for deletion in selected table.
Syntax
RECALL [Scope] [FOR<expll>] [WHILE <expl2>]
Default scope of RECALL is NEXT1.
You can use RECALL to recover records, provided PACK or ZAP has not been issued.
Example:
• RECALL ALL
• RECALL ALL FOR SAL > 10000
Replace
Updates table records. Default scope of REPLACE is ALL.
Syntax
REPLACE fieldname1 WITH expl [, fieldname2 WITH exp2] ... [FOR expl1]
[WHILE expl2]
For example:
REPLACE E_SAL WITH E_SAL + 100
Modify Structure Command
Syntax
MODIFY STRUCTURE
NOTE
Changing a field from one data type to another may not transfer the contents of the field
correctly, or at all. For example, if you convert a field of date type to numeric type, field
contents do not transfer.
Syntax
DISPLAY STRUCTURE
What is a Query?
According to the American Heritage Dictionary, a Query is a question, or we can say that
it is an inquiry. So when you query a database, you are asking it questions about data.
Using an employee file, you might ask the following questions:
With a little effort, you can come up with infinite questions. Both Queries and Views are
built in order to answer such type of questions.
2) Query by example (QBE): In this method, the system presents a blank record and
lets you specify the fields and values that define the query.
3) Query language: Many database systems require you to make requests for
information in the form of a stylized query that must be written in a special query
language. This is the most complex method because it forces you to learn a
specialized language, but it is also the most powerful.
Query Wizard: The Query Wizard provides an easy one to five step selection and
recovery of features and their attributes for display as maps, graphs, or animations. The
actual steps involved in a particular Query will depend on the Feature Types selected and
whether or not they have attributes, temporal and/or depth components associated with
them.
Use the Databases and Tables controls to locate and select the table you want to use.
In the Available fields window, select three or four fields you want to use from the
selected table, and use the arrow buttons to move them to the Selected fields window.
Limit your query by choosing only matching rows from both tables or all rows from
either table. By default, only matching records are included.
If you want to create an inner join, select only Matching Rows. If you want to create an
outer join, select all the records from one of the two tables.
You can reduce the number of records by creating expression that filters records from the
elected tables or views. You can create two expressions and connect them with AND or
OR. Choose Preview to see the records that will be returned based on supplied filter
criteria.
Step 5 – Finish
After you save the Query, you can open and modify it like any other Query in Query
Designer.
Now, you have to type a name for the query and save the query. Run the query by right
clicking on it.
QUERY DESIGNER
The Query Designer is a powerful tool for creating and editing profile queries,
intended for selecting or modifying table data.
The Query Designer window is divided into several tabs. The Designer tab is provided
for adding tables to the query and selecting the columns, included into the query. The
Options tab allows you to define various query properties, such as query name, type,
description, etc. The Conditions tab allows you to define the criteria for SELECT,
UPDATE, and DELETE queries. The Insert Values tab is intended for defining values in
INSERT queries. The Columns tab contains various properties of the selected query
columns: grouping and sorting for SELECT, or update values for UPDATE queries.
Select Query and then press New file button. You can also open Query designer from the
command window by using Create Query <new filename OR Modify Query <new
filename>
Data can be retrieved from a single database (and if required even from different
databases)
with the help of Add Table or View dialog box.
From the above dialog box if you want to open a free table (table independent of any
database) then press Other... push button.
Upper-half of the Query Designer dialog box displays the name of the open table along
with its structure.
If you want to add more tables, then right-click anywhere in the empty area in upper-half
of the Query Designer dialog box. A pop-up appears.
Executing a Query
What is a Form?
Nearly every application or user utility that you write in Visual FoxPro will include at
least one form (and probably quite a few). Forms are the powerful descendants of pre-
Visual FoxPro screens and they serve as the primary points of user interaction with both
the underlying data and business logic in most applications.
Visual FoxPro Form is a container class, capable of holding any number of other controls
or containers such as text boxes, command buttons, check boxes, page frames, or grids.
Forms provide a rich set of objects (an instance of a class, combining both data and
procedures. For example, a control on a running form is an object that can respond to user
(or system) events (an action, recognized by an object, for which you can write code to
respond. Events can be generated by a user action such as clicking the mouse or pressing
a key by program code, or by the system, as with timers.) so that users could accomplish
their information management tasks as easily and as intuitively as possible.
Form Designer
After you have created a new form Visual FoxPro launches Form Designer.
Form Designer
The most crucial elements of the Form Designer are the Form Canvas (the visual
representation of the form container), Properties Window (which shows all available
property, event and method (PEM) settings for the form and its controls) and the Form
controls toolbar (which makes available various controls that can be dropped onto the
canvas). The various toolbars are:
• Color Palette Toolbar This toolbar enables you to easily set the colors on a form and
any of its controls.
• Layout toolbar This toolbar provides the tools to properly align and size controls on
the form, modify the relative stacking order of overlapping objects and resize
controls.
• Data Environment Window This window shows the specified elements of Form's
Data Environment.
• Code Window This window shows the code that has been added to any of the
methods or forms or its controls.
Form Wizard
Creates a form for data entry from a single table. The size of the form is based on your
Maximum design area setting on the Forms tab, Options dialog box.
If you create a form within a database, the Form Wizard can use input mask and format
settings stored in the database. After you save the form, you can open and modify it later
like any other form in the Form Designer.
In this step, you can choose a free table or a table within a database as the source for your
pivot table. You can select only fields from a single table or view.
• In the Available fields window, select three or four fields you want to use from the
selected table, and use the arrow buttons to move them to the Selected fields
window.
You need to choose at least three fields; one each for row values, column values, and
data.
In this step, you can specify form style and button type.
In the Available fields window, select fields you want to use from the selected table, and
use the add> buttons to move them to the Selected fields window.
Step 4 – Finish
In this step, you have to type a title for the form and save the form for later use. Run the
form by right clicking on the form.
In Visual FoxPro for Windows, you can assign an icon to the form; the icon is displayed
when the window is minimized in Windows NT and in the title bar in Windows 95. To
assign an icon to a form, set the form's Icon property to the name of an .ico file.
Saving Forms
You need to save your form before you can run it. If you try to close the Form Designer
when the form has not been saved, Visual FoxPro prompts you to save or discard the
changes you've made.
You can also save a form, or a subset of the controls on a form, as a class definition. If
you intend to create subclasses based on the form or reuse the controls in other forms,
save the form as a class definition.
If you don't give the filename an extension, the default extension of .vex is added when
the file is saved. Once a form has been saved as a class definition, you can modify it with
the MODIFY CLASS command.
Running a Form
You can run a form directly from the interface or in program code.
To re-open the form in the Form Designer, close the form or choose the Modify Form
button on the toolbar.
You can also run the form by choosing Do from the Program menu, choosing Form
in the List Files of Type box, selecting the form, and choosing Do.
To programmatically run a form, include the DO FORM command in the code associated
with an event, in method code, or in a program or procedure.
Report Wizard
It creates reports using one free table or one table or view in a database. The wizard
prompts you with simple questions as you go through a series of steps, in which you
specify the source and fields that you want to use to create controls on your report.
Choosing GROUPING OPTIONS opens the GROUPING INTERVALS dialog box that
allows you to select levels of filtering that are relevant to the type of data contained in the
fields you selected for grouping.
Choosing SUMMARY OPTIONS opens a new dialog box that lets you specify from the
following list the type of calculation to perform on specific numeric fields:
You can also choose Detail and Summary only, or No Totals for the report.
Fields that you select as groupings here are not available in step 5, that is, Sort Records
Step 6 –Finish
Running a Report
To print a report:
• Select REPORT » RUN REPORT from the menu bar.
OR
• Use the command
Report Designer
Report Designer can be used to create and modify reports. When the Report Designer window is
active, Visual FoxPro displays Report menu and Report Controls toolbar.
• Choose FILE » NEW -> REPORT radio button -> NEW FILE push button
• From Project Manager, click Documents tab, select Report icon in the document list and
click on New button. Then select New Report.
OR
• Report Canvas is the visual representation of the report you are designing, the area onto
which you place fields, labels, or graphics.
• Report Designer toolbar enables you to have easy access to all the report toolbars and
several important functions.
• Report Controls toolbar enables you to drop any of six types of controls or objects onto
your report: labels, fields, lines, rectangles, rounded rectangles, and ActiveX/OLE
• Color palette toolbar enables you to specify colors for the background or foreground of
any control.
• Data grouping and Data environment buttons give you quick control over the
presentation of your data.
You can create controls on your report or label with the Report Controls toolbar. Click the button for
the control you want, position the mouse pointer on the report, and click the report to place the
control or drag it to size. On a report, you can double-click any control to display a dialog box to set
options. Report controls toolbar is displayed automatically when you open Report Designer.
Label Wizard
Label Wizard allows you to create labels from a Visual FoxPro database or a free table
using a selection of already provided standard label types. After you save a label created
by the wizard, you can open and modify it in the Label Designer.
Wizard Steps
This step is the key to the Label Designer because you must select a label format. FoxPro
has licensed the Avery Label formats, which gives you a wide selection label sizes and
shapes. Your selection of a label will then be carried over into the Label Designer
window and will automatically set the band length, width, and print characteristics. This
includes automatic setting for the standard "one-up", "two-up", "three-up" and "four-up"
label sheets (labels printed in 1 to 4 columns).
Add the fields in the order you want them to appear on the label. You can use the
punctuation, space, and new line buttons to format the label. Use Text box to add text. As
you add items to the label, the picture in the wizard window is updated to show
approximately how your label will look. Check this picture to see if the fields you have
chosen fit on the label or not. The text lines will extend beyond the bottom edge of the
label if there are too many lines. You can also use the Font button to change the font used
on labels.
In the end, you should have patched together something that looks like a normal label
(note the graphic presentation in the upper-left corner of the step 3 window. Then you
move on to step 4.
Step 5: Finish
This final step tells you that you have finished work in the wizard. If you have chosen to
create a Microsoft Word document, the wizard will open the document in Microsoft
Word. If you have chosen to create a text file, the wizard will prompt you to save.
Step 5 of Label
Extension of Label files is .lbx.
Label Designer
The Label Designer enables you to create and modify labels. When you activate Label
Designer window, Visual FoxPro automatically displays Report menu and Report
controls toolbar. Label Designer is almost identical to Report Designer but there are two
important differences. First, you can select the type of Label you want to use. Second,
only the Detail band has any output.
You can quickly create a label layout simply by clicking Quick Report on Report menu.
• To start a Label Designer.
• Select FILE » NEW » Label and then click on the New File button.
Another kind of data transfer, one that has traditionally held an important place in PC data
management, is called Mail Merge. Although the name is misleading (you can do far
more than send letters with the technique), mail-merge is the blending of data supplied by
a data management program with the documents provided by a word-processing program.
Word processors store data poorly (if at all), and database programs do not engage in
word-processing efficiently, hence the combination of the two is required. This can be
easily accomplished with the help of Mail Merge Wizard available in Visual FoxPro.
To use this wizard, you must have Microsoft Word for Windows (6.0 or higher) and
ODBC drivers for FoxPro installed on your computer (that should have been done when
you installed FoxPro) in order to create an MS-Word merged document.
Before you start the wizard, you must have in your mind what will be your data source
and which will be the Word document to be used. Mail Merge documents can be of any
kind — Visual FoxPro supports four document types in the wizard: Form Letter, Label,
Envelope, and Catalog.
Wizard Steps
In this step, you must have current version of Microsoft Word installed on your computer
if you select Microsoft Word.
If you select comma-delimited text file, the wizard will skip step 3 and step 4 and go
straight to the FINISH screen.
Step 3 allows you choose to create a new word-processing document or use an existing
document (which you must locate for the wizard).
Step 5: Finish
This final step tells you that you have finished work in the wizard. If you have chosen to
create a Microsoft Word document, the wizard will open the document in Microsoft
Word. If you have chosen to create a text file, the wizard will prompt you to save.
If you have selected Microsoft Word document (and new document in Step 3) then as
soon as you click on FINISH push button you immediately enter MS-WORD (in Mail-
Merge environment). Once you are in Word for Windows, you will need to complete the
document by adding appropriate text. Then you use Word's mail merge operations
(TOOLS » Mail Merge in Word menu) to actually run the mail merge and print the
document.
Cross-Tab Wizard
♦ Your Cross-Tab Query results will display a column for each unique value that exists
for the table field that you drag to the Data box.
SQL (Structured Query Language) is a database sublanguage for querying and modifying
relational databases. It was developed by IBM Research in the mid 70's and standardized
by ANSI in 1986.
SQL is a keyword based language. Each statement begins with a unique keyword. SQL
statements consist of clauses which begin with a keyword. SQL syntax is not case
sensitive.
SELECT statement
The SQL SELECT statement returns a result set of records from one or more tables.
It retrieves zero or more rows from one or more base tables, temporary tables, or views in
a database. In most applications, SELECT is the most commonly used Data Manipulation
Language (DML) command.
Syntax
SELECT column_name(s) FROM table_name
and
SELECT * FROM table_name
DISTINCT Statement
In a table, some of the columns may contain duplicate values. This is not a problem;
however, sometimes you will want to list only the different (distinct) values in a table.
The DISTINCT keyword can be used to return only distinct (different) values.
Syntax
SELECT DISTINCT column_name(s) FROM table_name
WHERE Clause
The WHERE clause is used to extract only those records that fulfill a specified criterion.
Syntax
SELECT column_name(s) FROM table_name WHERE column_name operator value
The OR operator displays a record if either the first condition or the second condition is
true.
ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set by a specified column. The
ORDER BY keyword sort the records in ascending order by default. If you want to sort
the records in a descending order, you can use the DESC keyword.
Syntax
SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC
BETWEEN Operator
The BETWEEN operator selects a range of data between two values. The values can be
numbers, text, or dates.
Syntax
SELECT column_name(s) FROM table_name WHERE column_name
BETWEEN value1 AND value2
IN Operator
The IN operator allows you to specify multiple values in a WHERE clause.
Syntax
SELECT column_name(s) FROM table_name
WHERE column_name IN (value1,value2,...)
GROUP BY Statement
The GROUP BY statement is used in conjunction with the aggregate functions to group
the result-set by one or more columns.
Syntax
SELECT column_name, aggregate_function(column_name) FROM table_name
WHERE column_name operator value GROUP BY column_name
HAVING Clause
The HAVING clause was added to SQL because the WHERE keyword could not be used
with aggregate functions.
Syntax
SELECT column_name, aggregate_function(column_name) FROM table_name
WHERE column_name operator value GROUP BY column_name
HAVING aggregate_function(column_name) operator value
Business Applications
In a very short span of time, computer has grown from a scientific curiosity to an
indispensable tool of modem society. There is hardly any scientific/technical or business
activity which is not in one way or the other, affected by modern data processing
techniques.
The human mind can handle only a limited number of things at a time. The digital
computer, on the other hand, can be programmed to compare, measure, calculate and
evaluate thousands of readings in an extremely short period of time.
The computer industry has become the fastest growing industry these days. The sale of
mainframe computers is increasing day by day. The computer industry has been further
pushed up by the introduction of mini computer and micro computers which are small,
cheap, reliable and very light. These are being routinely used for process control,
production testing, scientific instrument recording, in store check out systems, in
automobile test and evaluating systems, and medical monitoring etc.
Computers are now being used extensively in office administration to perform the routine
clerical work. Today, most large and medium sized organizations are almost totally
dependent on their computers. Routine uses of computers are given below:
WORD PROCESSOR
It is a software package to help in text processing. Words are processed. Processing
includes insertion, deletion changing, moving words, paragraphs etc. Word processing is
the preparation of type scripts, using computing facilities for the storage and manipulation
of text. For example, word processor has ability to merge name and addresses with
standard text so as to give impression that the latter is personalized even in case of
circular letter.
Hi-Tech Financial Accounting has got features so that you can export its reports to
Microsoft Word, a word processing and Mail Merge Program. You can also write letters
to various parties and store the details in the program database.
DATA BASE
It is simple collections of information (data) on a particular subject. Data base file allows
you to manipulate the data in desired form. So, data base allows us to work on facts and
figures to store and manipulate that data in any desired way. For example, from the same
basic information trial balance is prepared; trading and profit and loss account may be
prepared; list of debtors and creditors may be prepared; purchases and sales forecast may
be made and so on. So, an efficient data-base management is needed to provide flexibility
in uses of information.
Hi-Tech Financial Accounting uses MS Access and MS SQL server databases for robust
database connectivity.
SPREAD SHEET
It is one of the software programs which have increased the utility of computer for
accounting purposes. Spread sheet programs help you to draw vertical as well as
horizontal columns on a large sized paper. Each .column's length and breadth can be
adjusted according to suitability. Even when columns are once drawn subsequently these
can be altered, increased or decreased additional columns can be inserted, and existing
columns can be deleted. It is very useful for businessmen and professionals. It enables us
to study multidimensional data at one sheet and helps in arriving at logical decisions. For
example, if profit and loss account has been prepared for the year 1989 and you want a
comparison with 1987 figures and 1990 forecast then spread sheet shall enable you to
provide two additional columns on each side for inserting 1987 actual figures and 1990
forecast estimates.
In today's business environment, even small and mid-sized businesses have come to rely
on computerized inventory management systems. Certainly, there are plenty of small
retail outlets, manufacturers, and other businesses that continue to rely on manual means
of inventory tracking. Indeed, for some small businesses, like convenience stores, shoe
stores, or nurseries, purchase of an electronic inventory tracking system might constitute a
wasteful use of financial resources. But for other firms operating in industries that feature
high volume turnover of raw materials and/or finished products, computerized tracking
systems have emerged as a key component of business strategies aimed at increasing
productivity and maintaining competitiveness. Moreover, the recent development of
powerful computer programs capable of addressing a wide variety of record keeping
needs—including inventory management—in one integrated system have also contributed
to the growing popularity of electronic inventory control options.
Processing payroll can be one of the most complex tasks facing an organization. Besides
simply paying your employees, you will need to file taxes, submit reports and process
year-end data for tax-reporting purposes. To determine the best payroll system for your
company, consider the following points: