Type : CREATION_INTERNE
The macro-program does not read any tabular data. It operates exclusively on the character string provided as an input parameter (`i_absPath`) to extract its components.
| 1 | %MACRO _getAbsPathComponents (i_absPath = |
| 2 | ,o_fileName = |
| 3 | ,o_pathWithoutName = |
| 4 | ); |
| 5 | |
| 6 | %LOCAL l_pathElementCount; |
| 7 | %LOCAL l_fileNameStartPos; |
| 8 | |
| 9 | %LET &o_fileName=; |
| 10 | %LET &o_pathWithoutName=; |
| 11 | |
| 12 | %IF "%sysfunc(compress(&i_absPath))" NE "" %THEN %DO; /*if not empty input string*/ |
| 13 | %IF %sysfunc(index(&i_absPath.,/)) GT 0 %THEN %DO; /*input string contains dir separators*/ |
| 14 | %LET l_pathElementCount=%sysfunc(countw(&i_absPath.,/)); |
| 15 | %LET l_fileNameStartPos=%sysfunc(findw(&i_absPath.,%scan(&i_absPath,&l_pathElementCount,/))); |
| 16 | %LET &o_pathWithoutName=%sysfunc(substr(&i_absPath.,1,%EVAL(&l_fileNameStartPos. - 2))); |
| 17 | %LET &o_fileName = %sysfunc(substr(&i_absPath.,&l_fileNameStartPos.)); |
| 18 | %END; /*IF %sysfunc(index(&i_absPath.,'/')) GT 0*/ |
| 19 | %ELSE %DO; /*input string is a filename only*/ |
| 20 | %LET &o_fileName = &i_absPath; |
| 21 | %END; |
| 22 | %END; /*IF "%sysfunc(compress(&i_absPath))" NE ""*/ |
| 23 | |
| 24 | %MEND _getAbsPathComponents; |