AUSED( ) Function

Places table aliases and work areas for a data session into a variable array.

AUSED(ArrayName [, nDataSessionNumber])

Return Values

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.

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(atbl,1)
TABLEUPDATE(0,.T.,x)
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

ALIAS( ) | SET DATASESSION | USE | Working with Table Aliases