x = "/home/user1/tmp/coverage/test" y = "/home/user1/tmp/covert/operator" z = "/home/user1/tmp/coven/members" a = length(x) if a > length(y) then a = length(y) if a > length(z) then a = length(z) for i = 1 to a if mid(x, i, 1) <> mid(y, i, 1) then exit for next i a = i - 1 for i = 1 to a if mid(x, i, 1) <> mid(z, i, 1) then exit for next i a = i - 1 if mid(x, i, 1) <> "/" then for i = a to 1 step -1 if "/" = mid(x, i, 1) then exit for next i end if REM Task description says no trailing slash, so... a = i - 1 print "Common path is '"; left(x, a); "'"