* assume you have a cursor "foocur" with or without index tags SELECT foocur * get current tagname (empty string if none) lcCurrentTagName = ORDER("foocur") * get array of tag/expression info (no array created if none) ATAGINFO(aMyIndexes, "", "foocur") * now select into your new cursor SELECT * FROM foocur INTO CURSOR foocur2 readwrite * if we got an array with at least one row, index the new cursor * and set the order to match the original cursor * NOTE: VFP9 is required for the new second param on TYPE() to work IF TYPE("aMyIndexes",1) = "A" AND ALEN(aMyIndexes, 1) > 0 FOR lnLoop = 1 TO ALEN(aMyIndexes, 1) * 3=expression, 1=tagname, 5=ascending/descending, 4=filter lcCmd = "INDEX ON " + aMyIndexes[lnLoop, 3] + " TAG " + ; aMyIndexes[lnLoop, 1] + " " + ; aMyIndexes[lnLoop, 5] * NOTE: If you have FOR expressions on your indexes * you need to add that onto the lcCmd by using info in the * 4th column of the array * execute the command &lcCmd ENDFOR IF NOT EMPTY(lcCurrentTagName) SET ORDER TO TAG (lcCurrentTagName) ENDIF ENDIF