args List
static Slash = "\"
static N = "\n"
local CurNum, CurLast, CurDir, Str, This, Result, i, j, Item
local All = file.readall(List)
local Len = line(All, 0)
if(Len < 2)
quit
local v = vec.createfromlines(All)
if(v <= 0) do
messagebox("ok error", "Vector not created", "VEC plugin error")
quit
endif
v.sortstring
local Num = word(v[0], 0, Slash)
for(i = 1; i < Num; i++)
Str = word(v[0], i, Slash)
Result ++= "SUB=" ++ Str ++ "\n"
endfor
local Dir = word(v[0], Num - 1, Slash)
for(i = 1; i < Len; i++)
Str = v[i]
CurNum = word(Str, 0, Slash)
CurLast = word(Str, CurNum, Slash)
Item = CurLast ++ "=" ++ CurLast ++ N
CurDir = word(Str, CurNum - 1, Slash)
if(CurDir == Dir) do //same subdir
Result ++= Item
else
if(CurNum == Num) do //another same level subdir
Result ++= "ENDSUB\nSUB=" ++ CurDir ++ N ++ Item
elseif(CurNum < Num) do //end of subdir(s), level(s) up
Result ++= repeat("ENDSUB\n", Num - CurNum) ++ Item
elseif(CurNum > Num) do
for(j = Num; j < CurNum; j++)
This = word(Str, j, Slash)
Result ++= "SUB=" ++ This ++ N ++ Item
endfor
endif
endif
Num = CurNum
Dir = CurDir
endfor
Result = remove(Result, -2)
miscplugin.show_menu("Path", Result) |