||Re: table empty
Andy Taylor <firstname.lastname@example.org>
||Mon, 06 Jul 2020 06:35:43 -0400
I agree with everything said by Akshat and Mervyn.
I will chip in with "there are two things to get straight in your head".
Firstly, Ken's great book is aimed at the OODML way of doing things.
So XDML will not appear in it. However XDML (for the most part) is still alive and kicking in dBASE2019.
If you want to check if a command will work then the OLH and the command window is great for that.
Secondly, you cannot start off using OODML and then drop into XML without working out how to access the data.
With XDML you use "workareas" that grant you data access.
With forms you generally use an SQL query and various objects (datamodules, queries, rowsets, fields, etc) that allow data access, ultimately via _app.databases.
The two approaches are radically different but can live side by side. The browse object used in a form is an example of such a hybrid approach.
So ZAP is not going to work unless you have opened the table in a workarea, like the following:
USE myTable.dbf in select() alias MyTable; select MyTable; set safety off; zap; set safety on; use "" in MyTable
The OODML equivalent to the above line is _app.databases.emptyTable("MyTable.dbf")
Now, you can write either of the above as a function of the form and run it perfectly well from a PushButton on the form.
Neither method will work if you have MyTable already open in the same form via a query object.
However, you can get round that by temporarily setting the active property of the rowset to false.
Note that both methods assume that the table is present in the current folder.
The attached form demonstrates both methods, creating and using a "MyTable.dbf" along the way, showing one example of how to use both approaches in one form.
So, my message to you is that you don't have to move in one fell swoop to the new OODML methods.
You can pick and choose along the way, however there is as far as I know, no written guide to the hybrid approach (I worked it out by trial & error).
Used correctly XDML can actually be faster and quicker to use for some tasks than the OODML way, but in the long term it is, of course, doomed.
Hope that helps,
> Mervyn Bick Wrote:
> > On 2020-06-30 08:02, Akshat Kapoor wrote:
> > > If you are using use to open the table then the command is zap but it
> > > requires exclusive use of table.
> > You can ZAP a table any time it is open in a workarea. Exclusive use is
> > not required. This marks all records in the table as deleted. RECALL
> > will reinstate records, selectively if necessary, marked as deleted also
> > without the need for exclusive use.
> > PACK will physically remove deleted records from a table permanently.
> > For this dBASE requires exclusive use of the table.
> > Mervyn.
> Thank you all who helped with this answer.
> I have not done any coding since the \"infamous dBase 4 days\" so I have a lot to learn, however Ken\'s books are wonderful, but I still need guidance ?
> I am not using USE to open the table, just the standard \"sql\" with Query at the opening at the start of the form. I was not sure if ZAP and PACK were still in use in the latest versions of dBase, as they do not seem to be mentioned in Ken\'s books.
> He mentions EmptyTable, but as I said in my earlier appeal for help I can\'t seem to get it to work.
> Also I had a form with pushbuttons on it, and in the EVENT, I coded Do Batch.wfm or what ever other form I had. This worked well for about 10 days but now comes up with Batch.form.wfm does not exist. Have I changed a setting in dBase to cause, or is there a better way to connect to coded form ?
> Tony Hughes