Ehab,
No, it is much simpler.
Code: Select all
//--- meter class
class Tmeter from TData
method new
method browser
method add
method edit
method BrowseDelete
Hidden:
data lAdd as logical
endclass
..
method BrowseDelete(oBrw,oMeter)
if msgYesNo("Delete this record?")
::delete()
endif
::skip(1)
::skip(0)
if oBrw:eof()
::skip(-1)
::skip(0)
endif
oBrw:refresh()
return self
Keep in mind that this is a table class (we call them DBFs) so a browse function (method) doesn't really belong in this class, but we are doing it because it is easier than adding it to the TXBrowse class. You don't want to mess with the table delete method and it shouldn't have any interfaces in it--you may want to call it from other code (as we did above in the BrowseDelete() method).
Also you don't ever want to change the name of the method (like DBFDelete) because you want all tables to have a delete method (called "delete"). This is one of the basics of using OOP and it allows you to do things like pass any object and call the delete method. If each object had a different name for the delete method then you would have to code a large DO CASE statement and add to it for each new object--not good. You can't do this with procedural coding.
Code: Select all
function whatever( oObject )
oObject:delete()
return self
Also you do not need a new class for a new method. The method is part of the existing class--in your case TMeter.
See OOP is really simple.
James