Find common directory path: Difference between revisions

Find common directory path in BASIC256
(Find common directory path in BASIC256)
Line 337:
END IF
END FUNCTION</lang>
 
=={{header|BASIC256}}==
{{trans|GW-BASIC}}
<lang BASIC256>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); "'"</lang>
 
=={{header|Batch File}}==
2,169

edits