STATIC FUNCTION sLastFileByRoot(cFileRoot,cExt) * Return the name of the newest file for cFileRoot and cExt * cFileRoot: File root name of the file set to find, eg: TFMCAllEngage_ * cExt: File extension to use when looging for newest file, eg: csv MEMVAR cDataDrive // For life system this would be K: LOCAL aDir,; cLastFile := "" LOCAL cDirPath LogIt("c:\xbasecms\Error.txt","VAR2CHAR(cDataDrive) ["+VAR2CHAR(cDataDrive)+"]") LogIt("c:\xbasecms\Error.txt","cDataDrive ["+cDataDrive+"]") LogIt("c:\xbasecms\Error.txt","VAR2CHAR(cFileRoot) ["+VAR2CHAR(cFileRoot)+"]") LogIt("c:\xbasecms\Error.txt","cFileRoot ["+cFileRoot+"]") LogIt("c:\xbasecms\Error.txt","VAR2CHAR(cExt) ["+VAR2CHAR(cExt)+"]") LogIt("c:\xbasecms\Error.txt","cExt ["+cExt+"]") cDirPath := cDataDrive+PGI_LOCALUPLOAD+cFileRoot+"*."+cExt // PGI_LOCALUPLOAD is constant defined as "\PGI\Upload\" LogIt("c:\xbasecms\Error.txt","cDirPath ["+cDirPath+"]") aDir := DIRECTORY(cDirPath) // Line 3216 in prg from application IF LEN(aDir) > 0 ASORT(aDir,,,{|x,y| DTOS(x[F_WRITE_DATE])+x[F_WRITE_TIME] > DTOS(y[F_WRITE_DATE])+y[F_WRITE_TIME]}) // Sort in Descending Seq by Date & Time cLastFile := aDir[1,F_NAME] ENDIF RETURN cLastFile