Determines whether program files are compiled with coverage.

Syntax

SET COVERAGE on | OFF

Description

A coverage file is a binary file containing cumulative information on how many times, if any, dBASE Plus enters and exits (and thus fully executes) each logical block of a program. Use SET COVERAGE as a program development tool to determine which program lines dBASE Plus executes and doesn't execute each time you run a program.

A program file is either compiled with coverage or not. To disable coverage analysis, the file must be recompiled with coverage off.

There are two ways to control compilation with coverage. The first way is with SET COVERAGE, which can be either ON or OFF. The second way is with the coverage #pragma in the program file. The #pragma directive overrides the SET COVERAGE setting.

If a file is compiled with coverage enabled, dBASE Plus creates a new coverage file or updates an existing one. When dBASE Plus creates a coverage file, it uses the name of the program file, and changes the last letter of the extension to the letter "V"; unless the file is a .PRG, in which case the coverage file has an extension of .COV. For example, the coverage file for GRADES.PRG is GRADES.COV, and the coverage file for STUDENTS.WFM is STUDENT.WFV.

To view the contents of a coverage file, use DISPLAY COVERAGE or LIST COVERAGE. If the coverage file reveals that some lines aren't executing, you can respond by changing the program or the input to the program to make the lines execute. In this way, you can make sure that you test all lines of code in the program.

Coverage analysis divides a program into logical blocks. A logical block doesn't include commented lines or programming construct command lines such as IF and ENDIF. It does, however, include command lines within programming construct command lines. If your program doesn't contain any programming constructs (like IF, DO WHILE, FOR...ENDFOR, SCAN...ENDSCAN, LOOP, DO CASE, DO...UNTIL), the program has only one logical block consisting of all uncommented command lines.

The coverage file identifies a logical block by its corresponding program line number(s):

Line 1 * UPDATES.PRG
Line 2 SET TALK OFF  Block 1 (Lines 2-3)
Line 3 USE Customer INDEX Salespers
Line 4 SCAN
Line 5 DO CASE
Line 6 CASE Salesper = "S-12"
Line 7 SELECT 2  Block 2 (Lines 7-8)
Line 8 USE S12
Line 9 CASE Salesper = "L-5"
Line 10 SELECT 2  Block 3 (Lines 10-11)
Line 11 USE L5
Line 12 CASE Salesper = "J-25"
Line 13 SELECT 2  Block 4 (Lines 13-14)
Line 14 USE J25
Line 15 ENDCASE
Line 16 DO Changes  Block 5 (Lines 16-17)
Line 17 SELECT 1
Line 18 ENDSCAN
Line 19 CLOSE ALL    Block 6 (Lines 19-20)
Line 20 SET TALK ON

dBASE Plus writes the coverage file to disk when the program is unloaded from memory or when you issue a LIST COVERAGE or DISPLAY COVERAGE. To unload a program from memory, use CLEAR PROGRAM.