Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

WTable:ReDo() Method

------------------------------------------------------------------------------
Syntax
<oTable>:ReDo( [ <xValue> ] )   -->   self

Arguments
<xValue> is any user-specified data, such as RECNO().  This
data is passed to the ReDo() method in the parent of each
table object that might be affected by a change, without being
examined by the table class, so use any data you want (a
numeric, code block, array, etc.).  See the Note below.

Returns
SELF.

Description
This method provides a general-purpose mechanism for co-
ordinating access to tables which may be open more than once.
The idea is that each table object is responsible for
informing others using the same file, whenever the file has
been changed in a way that could affect them.

Note:  To use this mechanism, you must invoke the table
object's ReDo() method any time you make changes that could
affect other open instances of the file.  This is not done
automatically!  When you invoke the ReDo() method for a
table, the table class looks for any other current open
instances of the file.  It invokes the ReDo() method in the
parent of each other open instance, using code like:
     <oAnotherOpenTable>:oParent:ReDo( <xValue> )
Commonly, the oParent is a window displaying data, and you
want to re-read and re-display the data.

Example
// From SOURCE\OO\USERSRES\USERSMDI.PRG, this example has a dialog as the
// parent of the table, so a ReDo() method has been added to the dialog.
// This example uses RecNo(), but you can use anything convenient.
CLASS UsersDialog INHERIT WDialog
     PROTECT oUsers AS OBJECT // AS WTable
// . . .
     METHOD ReDo(nRec)        ; // nRec has changed, see ::Save()
            INLINE local lCur,;
                   lCur := ( (::oUsers:Area)->(RecNo()) == nRec ),   ;
                   ; // I don't think this dbSkip(0) should be needed
                   ; // but it is...
                   iif(lCur, (::oUsers:Area)->( dbSkip(0) ), ),   ;
                   iif(lCur, ::Update(), self)
ENDCLASS

METHOD OnInitDialog() CLASS UsersDialog
::oUsers = WTable{self, "users"}
(::oUsers:Area)->( dbGoTop() )
// . . .
return super:OnInitDialog()

METHOD Save() CLASS UsersDialog
local     nArea := ::oUsers:Area
if ::Valid
     (nArea)->( RLock() )
     ::Gather()    // update the fields from the vars
     (nArea)->( dbUnlock() )
     (nArea)->( dbCommit() )
     ::oUsers:ReDo((nArea)->( RecNo() ))
endif
return 1       // means msg has been processed


See Also: WTable:Axit() WTable:Init()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson