' ------------------------------------------
' Find common directory to all directories
' and directories common with other Paths
' ------------------------------------------
print word$(word$(httpget$("http://tycho.usno.navy.mil/cgi-bin/timer.pl"),1,"UTC"),2,"
") ' Universal time
dim path$(20)
path$(1) = "/home/user1/tmp/coverage/test"
path$(2) = "/home/user1/tmp/covert/operator"
path$(3) = "/home/user1/tmp/coven/members"
path$(4) = "/home/user1/tmp1/coverage/test"
path$(5) = "/home/user1/tmp1/covert/operator"
path$(6) = "/home/user1/tmp1/coven/members"
path$(7) = "/home/user1/tmp2/coverage/test"
path$(8) = "/home/user1/tmp2/covert/operator"
path$(9) = "/home/user1/tmp2/coven/members"
path$(10) = "/home/user1/tmp3/coverage/test"
path$(11) = "/home/user1/tmp3/covert/operator"
path$(12) = "/home/user1/tmp3/coven/members"
sqliteconnect #mem, ":memory:"
#mem execute("CREATE TABLE dirTree (seq,pos,dir)")
for i = 1 to 12
j = 1
[loop]
j = instr(path$(i),"/",j + 1)
if j > 0 then
dir$ = mid$(path$(i),1,j)
mem$ = "INSERT INTO dirTree VALUES (";i;",";j;",'";dir$;"')"
#mem execute(mem$)
goto [loop]
end if
next i
mem$ = "SELECT dir FROM dirTree GROUP BY dir HAVING count(*) = pos ORDER BY pos desc LIMIT 1"
#mem execute(mem$)
rows = #mem ROWCOUNT() 'Get the number of rows
if rows > 0 then
#row = #mem #nextrow()
print "====== Largest Directory Common to all Paths ========="
print #row dir$()
else
print "No common Directory"
end if
html "
| Seq | Path | Common Dir | Seq | With Path |
| ";seq;" | " html "";path$(seq);" | " html "";dir$;" | " html "";t1Seq;" | " html "";path$(t1Seq);" | " html "