>>JUSTPATH() will extract a path w/o backslash at the end from a file name. ADDBS() will add backslash at the end of a directory name if there isn't one. However, to get correct results you have to apply JUSTPATH() to a file name and ADDBS() to a directory names respectively.
>>
>>>
>>>I have :
>>>
>>>"c:/data/data1/myfile.txt " and i want "c:/data/data1/"
>>>OR
>>>"c:/data/data1 " and i want "c:/data/data1/"
>>>OR
>>>"c:/myfile.txt " and i want "c:/"
>>>OR
>>>"c:/data/myfile.txt " and i want "c:/data/"
>>>
>>>Thanks in advance or help.
>>>
>>>bernhart
The JUSTPATH() works in the above examples except for the second case, "c:\data\data1" -- here the function will return "c:\data". The function assumes the last part to be a filename when instead this may be part of the directory path. So incorrect results may be returned in this case. You have to know before issuing the command as to whether this is only a directory path or a path with a filename. You might try:
lcPath = "c:\data\data1"
IF DIRECTORY(lcPath,1)
lcPath = ADDBS(lcPath)
ELSE
lcPath = ADDBS(JUSTPATH(lcPath))
ENDIF