*****************************************************************************************
Function ATables(taDBFs)
*****************************************************************************************
** Function Name: A[rray of open] Tables
** Purpose : List all the table files currently open.
** Description : Essentially - a wrapper/extension for VFP's built-in AUSED() function,
** which gives only alias name and work area #, whereas we might need some
** more info as well (i.e. full path, open mode, index, etc.)
** After initial parameter validation, runs AUSED() function to determine
** the number of the table files currently open. If finds none - exits.
** If found - re-dimensions the given array-parameter with the following
** columns/structure:
** 1 - Full path to the open table file - as String;
** 2 - Alias name - as String;
** 3 - Work area number - as Integer;
** 4 - Is open in Exclusive mode - as Boolean;
** 5 - Is Updatable - as Boolean;
** 6 - Index tag - as String
** 7 - Record pointer's record # - as Integer.
** Parameters : Pointer on array (by ref.) - mandatory
** Returns : The number of open table files found if success (includes 0 if none),
** negative integer if errs.
** Side Effects : The array-parameter is re-dimensioned to accommodate the info on the
** found open table files.
** Notes : 1. Verbose on error, silent otherwise.
** 2. Can be used for programs written in VFP7 or newer versions.
** Author : Ilya I. Rabyy
** Revisions : 2010-10-12 - 1st draft.
** 2010-11-29 - by Ilya: added array element to store the current
** record pointer's position.
*****************************************************************************************
LPARAMETERS taDBFs
** Parameter's verifcation
IF VARTYPE(taDBFs) = "U"
= MESSAGEBOX([Invalid parameter passed: taDBFs s./b. a pointer on array.], 16, ;
PROGRAM() + [ - error: invalid parameter-array])
RETURN -1
ENDIF ()
LOCAL I, lnRet, lnEmpty
LOCAL ARRAY laAreas[1]
lnRet = AUSED(laAreas, .NULL.) && Number of open tables found
IF lnRet == 0 && No open table files found - we're done here!
RETURN lnRet
ENDIF ()
** Some open tables have been found - re-dimension and fill out the array-parameter
***********************************************************************************
** Next line was modified by Ilya on 2010-11-29, added array element to store
** the current record pointer's position
DIMENSION taDBFs[lnRet, 7] && taDBFs[lnRet, 6]
** End of modification by Ilya on 2010-11-29, added array element to store the
** current record pointer's position **
***********************************************************************************
FOR I = 1 TO lnRet
taDBFs[I, 1] = DBF(laAreas[I, 2]) && Full path to the DBF by work area # in laAreas
taDBFs[I, 2] = laAreas[I, 1] && Alias name in laAreas
taDBFs[I, 3] = laAreas[I, 2] && Work area # in laAreas
taDBFs[I, 4] = ISEXCLUSIVE(laAreas[I, 2], 1) && Obviously...
taDBFs[I, 5] = !ISREADONLY(laAreas[I, 2]) && Obviously...
taDBFs[I, 6] = ORDER(laAreas[I, 2]) && Tag name of the index set, if exists
** and set, empty string if ain't
taDBFs[I, 7] = MIN(RECNO(laAreas[I, 1], ;
RECCOUNT(laAreas[I, 1])) && Record pointer position
NEXT I
RETURN lnRet