PARAMETERS tcTable,tcOrder local lcCurWkArea,lcNewWkArea,lnInUseSpot lnInUseSpot=atc(tcTable+"*",pcRIcursors) IF lnInUseSpot=0 lcCurWkArea=select() SELECT 0 lcNewWkArea=select() IF NOT EMPTY(tcOrder) USE (tcTable) AGAIN ORDER (tcOrder) ; ALIAS ("__ri"+LTRIM(STR(SELECT()))) share ELSE USE (tcTable) AGAIN ALIAS ("__ri"+LTRIM(STR(SELECT()))) share ENDIF if pnerror=0 pcRIcursors=pcRIcursors+upper(tcTable)+"?"+STR(SELECT(),5) else lcNewWkArea=0 endif something bad happened while attempting to open the file ELSE lcNewWkArea=val(substr(pcRIcursors,lnInUseSpot+len(tcTable)+1,5)) pcRIcursors = strtran(pcRIcursors,upper(tcTable)+"*"+str(lcNewWkArea,5),; upper(tcTable)+"?"+str(lcNewWkArea,5)) IF NOT EMPTY(tcOrder) SET ORDER TO (tcOrder) IN (lcNewWkArea) ENDIF sent an order if pnerror<>0 lcNewWkArea=0 endif something bad happened while setting order ENDIF RETURN (lcNewWkArea)