table.REFRESH Function

Syntax

L Refresh()

Description

Perform network refresh, return True if changed.

Discussion

The <TBL>.REFRESH() method refreshes the data in the record buffer for the current record in the table referenced by <TBL>. This method is typically used when you have multiple Xbasic scripts operating on the same table, or you have a script that opens a particular table more than once. It ensures that the data in the record buffer for a particular record is not stale.

Example

The following Interactive Window session demonstrates when to use the <TBL>.REFRESH() method.

t1 = table.open("customer")
t2 = table.open("customer")
t1.recno() ? 1.000000
t2.recno() ? 1.000000
'delete the record in t1
t1.change_begin()
t1.delete()
t1.change_end(.T.)
't2 still points to record number 1
t2.recno() ? 1.000000
't2 indicates that the record is not deleted because the record buffer is stale
t2.is_deleted() -> .F.
'the .need_refresh() method confirms that t2 has a stale record buffer
? t2.need_refresh() -> .T.
'refresh t2's record buffer
t2.refresh()  
'now, the record is shown as Deleted
t2.is_deleted() -> .F.
't2's record buffer is not stale
t2.need_refresh() -> .F.

Here is another example.

'Both instances of the table point to same data
t1.Lastname -> "Cario          "
t2.Lastname -> "Cario          "
t1.change_begin()
'Change t1 to "Jones"
t1.Lastname = "Jones"
t1.change_end(.T.)
't1's record buffer is stale. It still has "Cario"
t2.Lastname -> "Cario"
t2.need_refresh()-> .T.
t2.refresh()
t2.lastname -> "Jones"
t2.need_refresh()-> .F.
t2.close()
t1.close()

See Also