PROTECTED PROCEDURE CheckValidPath ... If not CreatePath(lcPath) return "" endif .... ENDPROCto
PROTECTED PROCEDURE CheckValidPath ... If not CreatePath(lcPath) return "????" endif .... ENDPROCand add line
lcPath = Left(tcPath, Len(tcPath)-1)to CreatePath?
PROTECTED PROCEDURE CreatePath LPARAMETERS; tcPath IF !DIRECTORY(tcPath) THEN MKDIR ALLTRIM(tcPath) ENDIF RETURN DIRECTORY(tcPath) ENDPROC?
PROTECTED PROCEDURE CheckValidPath > lparameter tcPath > local lcPath, lcFile, lnHandle, lnRetVal > lcPath = addbs(tcPath) > if not CreatePath(lcPath) > return "????" > endif > lcFile = SUBSTR(SYS(2015), 3, 10) + ".txt" > lnHandle = fcreate(lcPath + lcFile) && test to see if files can be written to destination > if lnHandle < 0 > return "" > endif > lnRetVal = fclose(lnHandle) > erase (lcPath + lcFile) > return lcPath > ENDPROC > > >PROTECTED PROCEDURE CreatePath > lparameter tcPath > local lnRetVal, laFiles[1], lcPath > lcPath = Left(tcPath, Len(tcPath)-1) > lnRetVal = adir(laFiles, lcPath, "D") > if lnRetVal = 0 > md (tcPath) > endif > lnRetVal = adir(laFiles, lcPath, "D") > return (lnRetVal > 0) > ENDPROC