This section discusses required and optional parts of a command line, and includes rules for building expressions.
The structure of a command line is called its Each command line begins with a verb, and many commands also have one or more clauses that tailor the command to meet a need. The general syntax of a command is described below.
NOTE
You will find many exceptions to the general syntax paradigm given below. Not all commands use all the options given in this paradigm.
The exceptions are covered in the alphabetical listings. Read each entry in the subsequent chapters carefully, before using any language component.
command verb expression list scope
[FOR condition [WHILE condition [TO FILE filename TO ARRAY array list memvar
[ALL [LIKE/EXCEPT skeleton [IN alias command verb is the name of the dBASE command.
(square brackets) indicate that the item is optional.
(angle brackets) indicate that you must supply a specific value of the type required for the item in the brackets.
(slash) indicates an choice.
LANGUAGE REFERENCE -9
NOTE
1-10 ESSENTIALS
Do not type the square brackets, angle brackets, or slash when enter-ing a command.
list means a group of like items separated by commas.
expression list is one or more expressions, separated by commas.
They do not have to be the same data type (see the section below).
scope indicates the number of records the command can access.
The keywords for scope are:
• RECORD n to specify a single record by its number
• NEXT n for n records beginning with the current record
• ALL for all the records in the database
• REST for records from the current one to the end of the file
If a command accepts a FOR or WHILE clause, however, the conditions you specify in these clauses have precedence over scope
condition is a comparison between two or more items like Name
or a logical statement like EOF().
[FOR condition tells dBASE IV that the command applies only to records that meet the condition. If you use FOR, dBASE IV rolls the record pointer back to the top of the file, and compares each record with the FOR condition.
[WHILE condition begins processing with the current record in the database file, and continues for each subsequent record as long as the condi-tion is true.
[TO controls the output of the command. Certain commands allow you to send the output to a file, a printer, a designated array, or a memory variable.
Memvars (or memory variables, or just variables) are data values you tempo-rarily store in RAM. You assign each of these values a name so that you can later retrieve it from memory by name. Use these values to perform calcula-tions, comparisons, and other operations. You create memory variables with any of the following commands: ACCEPT, AVERAGE, CALCULATE, COUNT, INPUT, PARAMETERS, PRIVATE, PUBLIC, STORE, SUM, and WAIT.
The DECLARE command creates a special set of memory variables called an array. An array is a one- or two-dimensional table of values stored in memory. Each entry in the array is called an element, and each element in an array may be treated like a memory variable, and may be used in an expression.
Commands that allow output to a memvar also allow output to an array element.
[ALL [LIKE/EXCEPT skeleton directs dBASE IV to include or exclude the files, fields, or memory variables that match the skeleton. The skeleton is a general pattern that filenames, fields, or memory variable names may match. You may use the and symbols as wildcards in the skeleton. A represents any single character, while represents a group of any characters.
[IN allows you to manipulate the database file in another work area with-out SELECTing it as the current work area. The IN clause may contain the alias name, letter, number, or an expression that evaluates to an alias name, letter, or number. The USE command, however, requires a work area num-ber in the IN clause because no other alias exists until after the file is opened.
filename may be the actual name of a file as it is written on disk, or an indirect reference to the filename. Filenames are discussed earlier in this
Expressions
An expression is formed with combinations of:
Field names Memory Variables Array Elements Constants Functions Operators
System Memory Variables
So far in this chapter, you have already encountered memory variables, array elements, and functions.
A field name is the name of one field, or item of information, contained in every record of a database file. Lastname might be the field name of a field that contains last names. Each record in the database file would typi-cally have one last name entered in the Lastname field.
If the field is not in the currently-selected database file, you must qualify the field name with the alias name. Use the alias symbol between the field name and alias name. Note that you enter the alias symbol with two
keystrokes, a hyphen and a greater-than symbol For example,
means the Lastname field in the database file whose alias is Client.
I
LANGUAGE REFERENCE
NOTE