FUNCTION EDITCURS( tcCursorAlias ) * * OVERVIEW: This routine converts a readonly cursor into a writable * cursor by opening it again. * * PARAMETERS: tcCursorAlias - Alias of the cursor to be converted. * If omitted the ALIAS() is used. * * RETURNS: None * * HISTORY: 08/30/1997 (JME) * ******************************************************************************** LOCAL lnWorkAra, lcTmpDBFName, lcTmpCur, lnCurrArea, lcFilter * If a cursor to be converted has not been passed as a parameter, assume it * is the current alias. IF PCOUNT() = 0 tcCursorAlias = ALIAS() ENDIF * Save the current workarea. lnCurrArea = SELECT() * Make the cursor the current workarea. SELECT (tcCursorAlias) * Get the workarea of the cursor. lnWorkArea = SELECT(0) * Check the type of cursor passed. If the cursor is 'filtered' (no physical * disk presence), then it can't be opened in another workarea, thus * necessitating that a 'real' cursor be created. If it is a 'real' cursor, * it can be opened in another workarea and edited. * * A 'real' cursor file has a ".tmp" extension. IF AT( ".TMP", DBF() ) > 0 * Reopen the cursor AGAIN in a new workarea to make it editable. SELECT 0 * Get the file name of the cursor lcTmpDBFName = DBF(tcCursorAlias) * Reopen the file again. This makes it writable. USE (lcTmpDBFName) AGAIN ELSE * Force it to be a 'real' cursor by issuing a 'WHERE' condition in the * SQL statement that is NOT optimizable. 4/28/94 (FoxTalk 4/94) lcFilter = FILTER() IF EMPTY( lcFilter ) lcFilter = '.T.' ELSE lcFilter = lcFilter + ' .AND. .T.' ENDIF SELECT * FROM (DBF(tcCursorAlias)) ; WHERE &lcFilter ; INTO CURSOR lcTmpCur * Get the name of the physical file on disk. lcTmpDBFName = DBF('lcTmpCur') ENDIF * Reopen the editable cursor in the original workarea assigning it the original alias USE (lcTmpDBFName) AGAIN IN (lnWorkArea) EXCLUSIVE ALIAS (tcCursorAlias) * Close the temporary editable cursor USE * Reselect the original workarea SELECT (lnCurrArea) RETURN ENDFUNC && EDITCURS()The problem with using a writable cursor as a grid source, compared to say a view, is that you somehow have to move the changes in the cursor back to the source table(s). For that reason, most developers use either a table or view as the data source of a grid.