AUSED( ) Function
Places table aliases and work areas for a data session into a variable array.
AUSED(ArrayName [, nDataSessionNumber [, cTableName]])
Return Value
Numeric
Parameters
ArrayName
Specifies the name of the array containing the table aliases and work areas for a data session. If the array you specify does not exist, Visual FoxPro automatically creates the array. If the array exists and is not large enough to contain all the table aliases and work areas, Visual FoxPro automatically increases the size of the array. If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists, and AUSED( ) returns 0 because no tables are open in the data session, the array remains unchanged. If the array does not exist, and AUSED( ) returns 0, the array is not created.nDataSessionNumber
Specifies the data session number for which AUSED( ) returns the table aliases and work areas. If you omit nDataSessionNumber, AUSED( ) returns information about the current data session. Use SET DATASESSION to specify the current data session.cTableName
The array will only contain aliases of the table specified with cTableName.The current data session is used if you set nDataSessionNumber to the null value (.NULL.).
cTableName can be in the following formats, listed in the order in which Visual FoxPro searches for tables.
DatabaseName!TableName or DatabaseName!ViewName.
Path\DatabaseName!TableName or Path\DatabaseName!ViewName.
Database container (DBC) defined table name or view in the current DBC in the data session.
Simple or full table name.
Remarks
AUSED( ) returns the number of rows in the array, which is identical to the number of tables open in the data session.
AUSED( ) creates a two-dimensional array and places the aliases of tables open for the data session in the first column of the array. The second column of the array contains the tables' corresponding work area numbers.
The table aliases are placed into the array in reverse order that they were opened in. For example, the first array element contains the alias of the last table opened, and the last array element contains the alias of the first table opened. This ordering is useful when using TABLEUPDATE( ) on views that contain views. For example:
FOR x = 1 TO AUSED(aTableAliases,1)
IF CURSORGETPROP( "Buffering", aTableAliases(x) ) > 1 && Buffered
? TABLEUPDATE( 0, .T., aTableAliases(x) )
ENDIF
NEXT
Example
The following example uses AUSED( ) to create an array named gaInuse that contains the table aliases and work areas for tables open in the current data session. The number of open tables for the current data session is displayed, and the table aliases and work areas are then displayed.
OPEN DATABASE (HOME(2) + 'Data\testdata') EXCLUSIVE
USE Customer IN 0
CLEAR
? AUSED(gaInuse)
DISPLAY MEMORY LIKE gaInuse
CLOSE DATABASES
See Also
Tasks
How to: Create and Use Table Aliases