Use the DO command to run a program file, or double-click the file in the Navigator. If you run the program through the Navigator, the equivalent DO command will be streamed out to the Command window and executed. You can also call a .PRG program by name with the call operator, the parentheses, in the Command window; for example,

sales_report( )

will attempt to execute the file SALES_REPORTS.PRG. Since the operating system is not case-sensitive about file names when searching for files, neither is dBASE Plus.

A basic program simply contains a number of dBL statements, which are executed once in the order that they appear in the program file, from the top down. For example, the following four statements remember the current directory, switch to another directory, execute a report, and switch back to the previous directory:

cDir = set( "DIRECTORY" )

cd C:\SALES

do DAILY.REP

cd &cDir

Control statements, discussed earlier, are acted upon as they occur; they may affect the execution of the code that they contain. Some statements may be executed only when a certain condition is true and other statements may be executed more than once in a loop. But even within these control statements, the execution is still basically the same, from the top down.

When and if there are no more statement to execute, the program ends, and control returns to where the program was called. For example, if the program was executed from the Command window, then control returns to the Command window and you can do something else.