Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

ZAP

This may be the single most dangerous command in all of FoxPro, but it’s incredibly handy when you’re working interactively. ZAP permanently removes all records from a table. The name supposedly stands for “Zero And Pack.” ZAPped records cannot be recalled.

Usage

ZAP [ IN cAlias | nWorkArea ]

Although you can ZAP in a work area other than the current one, we really don’t recommend it. Using this command by itself is like striking matches; using it in another work area is like striking matches in a gas station.

ZAP is not a good database citizen. It doesn't call the Delete trigger for a table in a database. Instead, it neatly avoids all the work you've done to make sure the integrity of your database is maintained. This is a major flaw.

Due to the above and for lots of other reasons, never use ZAP in a program. It’s just too risky. See PACK for suggestions on alternatives. Actually, the one case where ZAP is acceptable is when you’re working on a temporary file in the first place, so no permanent data is at risk. In particular, it’s a great way to re-create a cursor without losing the grid that’s based on it. Simply ZAP and APPEND FROM your data instead of doing a SELECT.

So why do we think it’s incredibly handy? When you’re manipulating data manually—perhaps parsing older data to create a normalized database—it’s clean and simple to ZAP the target table between tests. Outside this kind of situation, we strongly recommend you avoid ZAP.

ZAP does respect SET SAFETY, so if you have it on, you are warned before you throw all your data in the garbage can.

Example

USE TestData
ZAP

See Also

Delete, Pack, Recall, Set Safety