TABLE.CURRENT Function
Syntax
Arguments
- slot
Optional. Refers to other open tables in the current session. A slot number ranges from 1 to the number of open tables in a session. If your current table is part of a set, Slot 1 is the primary table, Slot 2 is the first child, Slot 3 is the grandchild or the primary table's second child, and so on. All open tables, whether or not they are part of a set, will occupy slots in the session.
Description
The TABLE.CURRENT() method returns an object pointer to an open table in the current session. Use TABLE.CURRENT()without a parameter to return a pointer to the session's primary table. If no table is found in a particular slot, TABLE.CURRENT()creates an invalid object pointer. You can test the validity of an object pointer using the IS_OBJECT() function. You can also get a pointer to an open table using the TABLE.GET() method. For example, if you have opened a set and you want to get a pointer to one of the child tables in the set, (say "Invoice_Items"), you could use this command:
child = table.get("invoice_items")
Contrasting TABLE.OPEN()with TABLE.CURRENT()and TABLE.GET()
See TABLE.OPEN() for information on the difference between TABLE.CURRENT()and TABLE.OPEN().
Example
Count the number of open tables.
count = 1 while .T. tbl = table.current(count) 'Check to see if the table pointer, tbl, is valid. 'If not, then there are no more open tables. if .not. is_object(tbl) count = count - 1 exit while else count = count + 1 end if end while trace.writeln("Open tables = " + ltrimcount-1?)
See Also