JavaScript Editor js editor     Web development 



Main Page

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

AUSED(ArrayName [, nDataSessionNumber [, cTableName]])

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.

Return Value

Numeric

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:

В Copy Code
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.

В Copy Code
OPEN DATABASE (HOME(2) + 'Data\testdata') EXCLUSIVE
USE Customer IN 0
CLEAR
? AUSED(gaInuse)
DISPLAY MEMORY LIKE gaInuse
CLOSE DATABASES

See Also



JavaScript Editor js editor     Web development