Dbase III Plus Tutorial
Dbase III Plus Tutorial
Dbase III Plus Tutorial
Computing Services
Table of Contents
1 Introduction........................................................................................................3
3 Initial Preparation...............................................................................................3
4 The Assistant......................................................................................................3
4.1 Using the Menu ......................................................................................4
4.2 Getting Help ...........................................................................................4
4.3 Simple Steps for the Beginner................................................................4
Should you wish to comment on any aspect of this document, or associated software, please direct your comments to:
Select dBASE III PLUS from the menu and press , you will enter a sub-menu allowing you a choice of printers and an
option to use the tutorial. You should choose Option 1 to use the Network printer on your campus. Only choose the
Local printer if you have a printer attached to your machine.
The tutorial option loads an introductory package (Learning dBASE III PLUS) on the system. This uses the Assistant and
is an excellent way of demonstrating the concepts. You will need to borrow "Learning dBASE III PLUS" from Computer
Reception.
To leave dBASE III PLUS select Quit dBASE III PLUS from the Set Up Menu and press .
3 Initial Preparation
dBASE III PLUS allows for the collection and management of data in two ways:
An entry in the database relating to one item is called a record, and items of information within the record are stored in
fields. Each field is given a name and description. The field name should be relevant to the information held in it, the
field description includes the length and the type of data.
Consider the structure of the data to be entered. Take time to plan this.
What name should be given to each field? Make names meaningful, they can be up to 10 characters long, contain
letters or numbers and the underscore character(_).
How many fields do you need for each record? Think about how you are going to access the data. All the
information could in theory be held in one field but this would make it difficult to search for specific information
within the database.
How wide should each field be (maximum)? Some standard field types have set widths (LOGICAL - 1, DATE - 8,
MEMO - 10), for others you decide. Allow for the largest entry in your database, or consider abbreviations.
What type of data is to be held in the field? Is the data to be used in calculations or decisions?
4 The Assistant
The Assistant provides you with a menu based selection for file management. As the name implies it is there to help you
build a database using selected commands. The command in use is built up as you select from options presented in
sub-menus. It is simpler to use than the control language.
On entering dBASE III PLUS you are presented with a . prompt. Type ASSIST to use the Assistant.
3
4.1 Using the Menu
Select a Menu with type the first letter of the menu name. Choose a menu option with and , press to
select it, brief instructions are displayed on the bottom of the screen.
You cannot select options from most menus unless you have opened a database file; your first selection should either be
to create a new database, or select an existing one.
In some modes you are presented with a sub-menu holding lists of files, field names or options. If the list is larger than
the window use and to scroll. Where a sub-menu allows you to select more than one item the selected item will be
marked with , continue your selections then press or to leave the sub-menu.
Where you are setting up additional files such as reports use F10 to display the fields available from the database in use.
If you are asked to enter a parameter at the keyboard, for instance, when setting conditions to be met, the information box
will inform you whether quotes .. are expected.
Care: while field names are not case sensitive, the data held within the field is, an important consideration when
searching for specific records.
The status bar, at the bottom of the Assistant menu displays the selected menu, the drive and file in use, and the current
position and number of records in the file. Below the bar is brief help information. Directly above it the active
command is displayed. The active command is built as options from sub-menus are selected.
5.1 Setup
The Setup menu is used to open files and Exit from dBASE III PLUS. You choose the file type to open, the Drive on
which the file resides and finally the file name.
5.1.3 Query
Look at specific records, a Query file containing details of the conditions to be met must exist. Refer to the manual.
4
5.1.4 Catalogue
Group your files. Used when holding several databases on a drive or disk. Refer to the manual.
5.1.5 View
Select files to view, links several files, and links index files to a specific database. A view file must exist first containing
the relevant selection data. Refer to the manual.
5.2 Create
The Create menu allows creation of database and other file types. As in the Setup menu you must select a drive before
entering your filename.
Enter the name of the file: type in your new file name and press . Make the name relevant, do not enter a file
extension, dBASE III PLUS provides .dbf. A window appears allowing specification of the file structure.
2. Select a field type - press the space bar until the correct type is displayed or type the first letter of the field type,
and press .
3. Enter the field length (maximum width) and press . Note, decimal places and the decimal point are included in
the length.
5.2.2 Format
Create a customized screen for data input using APPEND or EDIT mode. This allows you to display text on the screen,
and to put more than one field on the same line thus enabling large records to be displayed on a single screen.
5.2.3 View
Creates a view file defining the relationships between database(s), index files etc.
5.2.4 Query
Create a query file to limit the records accessed in the database in use. Only those records meeting the conditions will be
accessed.
5.2.5 Report
Defines a file specifying the layout of a report, usually for printing. Select the drive the report file is to be written to
(choose the same drive as you chose for your database) and enter a filename for your report. Relate the filename to the
database; do not enter an extension, it will be given an extension of .frm.
The Create Report screen appears, with the Options menu open. Highlight the option to use/alter and press . Type in
your specific data/information.
to the Groups menu to produce group reports. The database file must be sorted or indexed on the field within the
database relating to a specific group, then by selecting that field you can have page breaks and/or group totals between
groups of similar types of records.
5
Figure 1- The Assistant Menu
to the Columns menu to set up the main body of your report. Select Contents and press then F10 and select the
field to be displayed. Notice the width will alter to the size of the selected field. Select the Heading and press , type in
the column heading required. Headings can be up to four lines of text, use the semi-colon to insert blank lines or to force
text onto the next line.
Press PgDn to move to the next column and repeat the process until you have defined all the columns on your report.
Care: plan the report first, to print on the default printer you cannot define a report width of 300 characters if your
printer default is only 80 characters wide.
To insert a column - PgUp/PgDn to move to the column after the desired insertion, and press Control-N. You will be
given a blank columns menu.
The Locate option displays a list of fields selected in each column. Use it to check that all report fields are entered
correctly.
Save the report, to Exit Menu and select Save. Choose Abandon if you want to cancel the operation.
5.2.6 Label
Create a label form file. You define the label size, the number of columns, and enter the fields to be printed in a similar
manner to the Report function.
5.3.1 Append
On selection the screen shows a blank record structure. Type in the field details. If you fill the field you are automatically
moved to the next and the bell sounds. Press if the data does not fill the field. Care: if you do press when the bell has
sounded - the will act as the end of the next field and will move you on too far, you will need to use your cursor keys to
return to the correct place to continue.
6
When all the data is entered press Control-End to save the final record and leave append mode. (Pressing at the
beginning of a blank record will also end APPEND mode.
You can also use INSERT and BROWSE to add records to the file.
5.3.2 Edit
Select to alter a record. Use the Position menu to select the correct position in the file first. The current record is
displayed on the screen. If the correct record is not selected, move one record at a time using PgDn and PgUp. Edit using
the , , , , to move to the field to be altered and retype the character(s) necessary. Delete information using
Control-Y. The edit menu at the top of the screen shows necessary instructions and cursor movements. Press
Control-End keys to save your alterations or use the Esc key to abort.
5.3.3 Display
Shows up to 15 records at a time.
5.3.4 Browse
Display edit and append records. Useful if you need to alter several records. It displays several records at one time, and
the necessary instructions are displayed in a menu at the top of the screen. If the records are longer than 80 characters
you cannot see all the record on the screen at once. You can move across the record a field at a time using Control
and thus display the relevant field for alteration.
5.3.5 Replace
Use to replace the contents of a field for all records or for records meeting a specified condition. Refer to the manual for
further information.
5.3.6 Delete
Records can be marked for deletion or permanently removed from the database. Choose Build a search condition from
the sub-menu. Select the desired field and operation and type in the string to be searched for (eg FIELDX = mytext).
When you have entered your conditions choose No more conditions and select Execute the command. All records
matching the chosen conditions will be flagged for deletion. Use the Browse command to check that the correct records
have been marked before permanently removing the records.
5.3.7 Recall
Records flagged for deletion can be Recalled at this point if necessary.
5.3.8 Pack
Remove flagged records permanently.
5.4 Position
The Position menu allows you to move to a specific record in the database dependant on specified conditions.
5.4.1 Seek
looks for a specific key within an indexed database. See the manual for further information.
5.4.2 Locate
looks for a specific condition and stops at the the first record meeting it. The default scope is to search the whole
database. Choose Build a search condition, select the field to be examined from the field list on the screen, choose the
condition to be met (equal to, greater than etc) and type in the value, this will be an actual name or value you know
should appear in the field selected. Choose Execute the command and the file is searched. Use a command such as edit
to display and alter the record.
5.4.3 Continue
Used in conjunction with locate to find further records meeting the condition(s) specified in the previous locate command.
5.4.4 Skip
Moves the record pointer forward or back a specific number of records. Select skip and enter a number, a negative value
moves backwards.
7
5.5 Retrieve
The Retrieve menu covers report options. The first two commands produce a simple list of fields and if the field sizes to
be viewed are wider than the screen or paper then the results will be untidy. When creating final reports you will need to
use the Report function.
5.5.1 List
Produce a list of all or part of the information in the database. From sub-menus select Construct a field list and choose
the desired fields, select Build a search condition and specify conditions to be met. Finally choose Execute the
command and answer Y/N to the question Direct the output to the printer?
5.5.2 Display
Similar to list except it pauses after displaying 20 records prompting Press any key to continue... useful when viewing
records on the screen.
5.5.3 Report
Uses a report specification held in a previously created report form file. Select the file to be used from the sub-menu then
choose Execute the command and answer Y/N to the question Direct the output to the printer?
You can print reports for specific records by selecting the search and scope conditions. See the manual for further
assistance.
5.5.4 Label
Uses previously defined label file to print columns of labels.
5.5.5 Sum
Use on numeric data to obtain the sum of all selected numeric fields within the database that apply to the selected
conditions.
Select Construct a field list and select the field(s) to be summed, then Execute the command to sum all the records
within the database. If you want to sum only specific records then choose Build a search/scope condition before
execution and specify the parameters to be met.
5.5.6 Average
Obtain the arithmetic mean of selected numeric fields within the database applying to selected conditions. Similar to Sum.
5.5.7 Count
Gives the number of records matching specified conditions.
5.6 Organise
The Organise menu arranges the order of the records in your database.
5.6.1 Index
Allows you to set up an index for the database in use. You are prompted:
Enter an index key expression - press F10 to select a field from the field list. If you need to index on more than one
field separate your field selection with +, press to complete index key selection.
Select the drive on which to write the index file, choose the same drive as the original database, and enter name of the
file, the file will automatically be given the extension .ndx. The data is now selected in the order of the index key.
The records in the database are still in the same physical order and the database may be selected with or without the index
in use. When the index is in use new records added to the file are automatically indexed.
5.6.2 Sort
Rearranges the records in the database by creating a new file, the sort can be made in ascending or descending order. To
examine records after sorting you must reopen the Setup menu and select the sorted file as the file in use. Remember if
you update after sorting you will need to re-sort.
5.6.3 Copy
Duplicates the database in use. The whole file or selected parts can be copied by selecting specific fields to be copied
and/or defining parameters to be met before a record is copied.
8
5.7 Modify
The Modify menu allows amendments to be made to file specifications. It is identical to the Create menu except that you
are offered a list of existing files instead of being asked to enter a new filename. You can insert or delete existing records
or fields. The menu at the top of the screen will display the cursor controls necessary.
5.7.2 Format
Modify a customised screen format file.
5.7.3 View
Modifies a view file from the working environment. Stores the current settings and relationships.
5.7.4 Query
Modify a query file
5.7.5 Report
Create/edit a report form file
5.7.6 Label
Create/edit a label form file
5.8 Tools
Allows the use of certain DOS utilities to save exiting the package. In all options you are prompted.
5.8.3 Directory
Select drive to be examined and file types to be displayed.
5.8.4 Rename
Change the name of a file.
5.8.5 Erase
Delete a file, you cannot delete a file that is in use.
5.8.7 Import
Creates dBASE III PLUS files from a file exported for use in other packages. Refer to the manual.
5.8.8 Export
Creates a single file from the dBASE III PLUS files in use for use by other packages. Refer to the Manual.
9
General Syntax:
Examples:
? 17 - 11 * 100 returns the result of the calculation - 600.
CONTINUE continue the locate and return the record number for the next
occurrence of name = Smith.
This section lists commands available in dBASE III PLUS no further instruction is offered here, it is expected that those
using the command language will refer to the reference manual available from Computer Reception.
APPEND [BLANK]
add record(s) to the active database.
ASSIST
use the Assistant Menu.
BROWSE [FIELDS <field list>] [LOCK <expN>] [FREEZE <field>] [NOFOLLOW] [NOMENU]
[WIDTH <expN>] [NOAPPEND]
full screen viewing of records allowing editing and appending.
CANCEL
stop execution of a command file.
CLEAR
erases the screen
10
CLEAR ALL
close all open database files, release all memory variables
CLEAR FIELDS
releases field lists created by SET FIELDS TO
CLEAR GETS
clears all pending GETS
CLEAR MEMORY
release all memory variables
CLEAR TYPEAHEAD
empty type-ahead buffer before requesting keyboard input.
CLOSE <filetype>
close files of a specified type where the file type refers to one of the following - ALL,ALTERNATE, DATABASES,
FORMAT, INDEX, PROCEDURE.
CONTINUE
continue a search specified in the last LOCATE command
11
CREATE SCREEN <.scr filename>/?
create a customised screen for data input using APPEND or EDIT mode. This allows you to have instructions on the
screen when entering data, and to put more than one field on the same line.
DISPLAY [<scope>] [FIELDS] <expression list>] [WHILE <condition>] [FOR <condition>] [[OFF]
[TO PRINT]
displays up to 20 records at a time on the screen or the printer
DO CASE
CASE <condition>
<command>
[OTHERWISE]
<commands>
ENDCASE
allows execution of commands when a certain condition is met.
DO WHILE <condition>
<commands>
ENDDO
allows execution of commands while a condition is true.
EJECT
advance the paper to top of page
ERASE <filename>/?
delete a file
EXIT
transfer control to the ENDDO of a DO WHILE statement
12
EXPORT TO <filename> [TYPE] PFS
build a pfs file from a dBASE III PLUS file, all ancilliary files in use will be exported into the one file.
GO/GOTOBOTTOM/TOP/<expN>
position record pointer to a specific record.
HELP [<keyword>]
access the help file for assistance.
IF <condition>
<commands>
[ELSE]
<commands>
ENDIF
conditional execution of commands
LIST [OFF] [<scope>] [<exp list>] [WHILE <condition>] [FOR ] <condition>] [TO PRINT]
list/print records for file in USE.
LOOP
transfer control to start of DO WHILE loop
13
MODIFY COMMAND <filename>
create/modify a command file.
MODIFY STRUCTURE
amend the structure of the file in USE.
ON ERROR/ESCAPE/KEY <command>
execute the specified command when an error occurs or the escape key/any key is pressed
PACK
permanently removes records marked for deletion from the database in USE.
PROCEDURE<procedure name>
define the start of a new procedure
QUIT
end dBASE III PLUS session closing all files.
READ [SAVE]
allows entry of data in GET fields
REINDEX
rebuilds active index files
14
RESTORE FROM <.mem filename> [ADDITIVE]
retrieve memory variables from a memory file.
RESUME
resume processing of a suspended program
RETRY
error recovery option - re-execute the command.
RUN <command>
execute a DOS command or executable program
SEEK <expression>
find the first record whose key matches the expression.
SET
set dBASE III PLUS control parameters
15
SET DEBUG on/OFF
error location, ON sends output of SET ECHO commands to the printer.
16
SET INDEX TO [<.ndx file list>/?
opens the specified index files
17
SKIP [<expN>
[+/-n] move forwards/backwards through the file in USE.
SORT <scope> TO <new filename> ON [/A] [/C] [/D] [,<field2> [/A] [/C] [/D]...] [WHILE
<condition>] [FOR <condition>]
creates new database file in sorted order, use /A for ascending, /D for descending order. /C differentiates between upper
and lower case. Default is /A, up to 10 fields can be specified as the sort key.
SUSPEND
debugging tool, option invoked by pressing <ESC> and choosing suspend. You can then amend a command in the
HISTORY buffer and execute the RESUME program execution.
ZAP
deletes all the records in the active database.
[<command>]&& <text>
add comment to same line as command
18
Example: The expression in brackets always refers to a character string, a numeric string is often required as several
commands work on a specified number of characters within the character string.
? FORENAME,SURNAME
would return Frederick Jones
? TRIM(FORENAME),SURNAME
would return Frederick Jones - the comma generates a single space
? TRIM(FORENAME)+SURNAME
would return FrederickJones - the + means no spaces between.
TRANSFORM(<ecp1>,<expC>)
uses PICTURE format on data.
19
7.4 Conversion Functions
Used to convert one type of data to another
Example: Convert character field to numeric. If a character is non numeric the value zero is returned.
Example: READKEY returns a code number representing the key pressed on exiting from a full-screen command. Eg.
CTRL-W to leave edit mode.
INKEY( ) returns code for most recent key pressed during execution.
READKEY( ) return exit key code when leaving full screen mode.
20
7.8 Specialised Test Functions
Example:Return Logical True if the end of file is found.
DO WHILE .NOT. EOF( ) execute the DO loop until End File Marker
...... is found
ENDDO
You can have up to 1,000,000,000 records in a file, each record can be up to 4,000 bytes long and can contain a
maximum of 128 fields. Up to 15 files of any type, 10 of which can be databases, can be open. Up to 7 index files and 1
format file can be attached to one database file.
21
File Ext File Type Description
.cat Catalogue store the names of files used together in a catalogue. Eg. your database file together with the
index and query files used regularly
.dbf Database main database holding the data in records and fields
.bak Backup Backup of a database file made when the structure of the file is modified
.tbk Memo backups backup of the memo file following modification of file structure
.fmt Format your own display format for the database - used for printing and screen display
.ndx Index view the data in the order specified by the index
.qry Query display only those records meeting the conditions specified in this file
.vue View contains field names to be displayed from one or more specified databases.
character maximum 254 bytes may include letters, numbers, and punctuation symbols, as well as numbers that
will not be calculated, such as phone numbers or STD codes.
numeric maximum 19 bytes may include only numbers that can be calculated, a decimal point, and a leading
plus (+) or minus (-) sign. Numeric entries represent data that is to be calculated,
do not use this data type for phone numbers or STD codes.
date fixed 8 bytes a date. dBASE III PLUS specifies the format: for example, 09/28/89 for
September 28 1989.
Note: the format is American - you can set it to British at command level before
beginning your session.
logical 1 byte a true/false or yes/no response (for example, to the question: "PAID?").
memo maximum 5000 bytes an entry containing text of up to 5,000 characters. It can be created with a text
Memo Field fixed 10 editor or word processor and is stored in a separate file on your disk. dBASE III
bytes PLUS automatically gives the field a length 10.
22
8.3 Command Syntax and Use
The Command line has a maximum length of 254 characters. Commands are entered at the dot prompt. Each command
begins with the instruction or verb and the general syntax is:
Code Description
<> you enter the item - do not type the angle brackets
<expression list> one or more expressions separated by commas, contains field names, memory variables, constants, functions
and operators.
8.4 Operators
There are four types of operators used on differing types of data
+ Addition
- Subtraction
* Multiplication
/ Division
** or ^ Exponentiation
() Grouping
Relational Operators generating logical results True/False, used on character or numeric data, as long as both fields in
the individual comparison are the same.
23
Logical Operators give a logical result on comparing two expressions
Memvar names: can be up to ten characters long, must begin with a character and can contain numbers and the
underscore character. Do not call a memory variable by a command name.
Memvar Sizes: you can have up to 256 active variables with a maximum combined size of 6,000 bytes.
24