.T. = Delete table records, .F. = Do not delete table records.
Delete all the records in the table if safety is TRUE.
The <TBL>.ZAP() method removes all records from the table referenced by the <TBL> pointer, but preserves the table structure. You must supply a Safety_Flag to confirm the action, and prevent accidental loss of data. If the Safety_Flag is FALSE (.F.), the Zap operation does not occur. The Zap operation requires exclusive access to a table. You cannot have a form or browse open that is based on the table. If exclusive read/write access cannot be obtained, the <TBL>.ZAP() method causes an error. Use the <TBL>.FILE_MODE_GET() method to check if the table is opened in exclusive mode.
Before zapping the table confirm action with the user and set the safety flag appropriately.
dim tbl as P dim table_to_zap as C table_to_zap = ui_get_file("Zap which table? ", "Table(*.DBF)", "", "X") if (table_to_zap = "") then end end if tbl = table.open(table_to_zap, FILE_RW_EXCLUSIVE) 'Compute the Message Type code code = UI_QUESTION_SYMBOL + UI_YES_NO response = ui_msg_box("Zap Data","Are you sure? ", code) if (response = UI_YES_SELECTED) then 'Yes was selected safety = .T. else safety = .F. end if 'Next, check that user has exclusive access tbl = table.current() if (tbl.file_mode_get()= FILE_RW_EXCLUSIVE) then tbl.zap(safety) else ui_msg_box("Zap Data","You do not have exclusive use of the table.", UI_STOP_SYMBOL) end if