Find common directory path: Difference between revisions
Content deleted Content added
Find common directory path in BASIC256 |
Find common directory path in Yabasic |
||
Line 3,051: | Line 3,051: | ||
The common directory path is: /home/user1/tmp |
The common directory path is: /home/user1/tmp |
||
</pre> |
</pre> |
||
=={{header|Yabasic}}== |
|||
{{trans|GW-BASIC}} |
|||
<lang yabasic>x$ = "/home/user1/tmp/coverage/test" |
|||
y$ = "/home/user1/tmp/covert/operator" |
|||
z$ = "/home/user1/tmp/coven/members" |
|||
a = len(x$) |
|||
if a > len(y$) a = len(y$) |
|||
if a > len(z$) a = len(z$) |
|||
for i = 1 to a |
|||
if mid$(x$, i, 1) <> mid$(y$, i, 1) break |
|||
next i |
|||
a = i - 1 |
|||
for i = 1 to a |
|||
if mid$(x$, i, 1) <> mid$(z$, i, 1) break |
|||
next i |
|||
a = i - 1 |
|||
if mid$(x$, i, 1) <> "/" then |
|||
for i = a to 1 step -1 |
|||
if "/" = mid$(x$, i, 1) break |
|||
next i |
|||
fi |
|||
REM Task description says no trailing slash, so... |
|||
a = i - 1 |
|||
print "Common path is '", left$(x$, a), "'"</lang> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |