local Move if(ctrl) Move = 1 local Path = trim(file.folder(x9), " ", 3) ++ "\" local Quote = esc(?+\"+, ?+\+) Path = trim(Path, Quote, 3) local Name = trim(file.nametype(x9), Quote, 3) local Source = Path ++ "descript.ion" if(not file.validpath(Source)) do messagebox("ok error", "File " ++ Source ++ " is missing", "No comment file") quit endif v = vec.create(1, 1) if(v <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error #1") quit endif w = vec.create(1, 1) if(w <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error #2") quit endif N = vec.create(1, 1) if(N <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error #3") quit endif local fh = file.open(Source, "r") local i, Str, FileName, Comment, Result, Where, Ind, Comms, NotComms local CR = esc(?+\n+, ?+\+) local OpQuote = esc(?+\d171+, ?+\+) local ClQuote = esc(?+\d187+, ?+\+) local Delim = ". " local Config = profolder ++ "scripts\ini\CopyComment.ini" if(fh > 0) do for(not(file.eof(fh))) Str = file.readstring(fh) if(not Str) continue FileName = word(Str, 1) if(file.validpath(Path ++ FileName)) do vec.insert(v, Comms, FileName) Comment = select(Str, length(FileName) - length(Str) + 1) else FileName = word(Str, 1, Quote) if(not file.validpath(Path ++ FileName)) do vec.insert(N, NotComms, Str) NotComms++ continue endif vec.insert(v, Comms, Quote ++ FileName ++ Quote) Comment = select(Str, length(FileName) - length(Str) + 3) endif if(FileName == Name) do local mpDlgText = "File " ++ Name ++ " has the " ++ OpQuote ++ Comment mpDlgText = mpDlgText ++ ClQuote ++ " comment already!\n" mpDlgText = mpDlgText ++ "Choose where to put new comment relative " mpDlgText = mpDlgText ++ "to the existing one." local mpDlgCaption = "CopyComment Script" local mpIcon = "QUESTION" Ind = Comms Where = miscplugin.messagebox(1, "&Before", "&After", "&Instead", "&Cancel") if(Where == "&Cancel") do file.close(fh) vec.destroy(v) vec.destroy(w) vec.destroy(N) quit endif endif vec.insert(w, Comms, Comment) Comms++ Result = Result ++ "File: " ++ FileName ++ ", comment: " ++ OpQuote ++ Comment Result = Result ++ ClQuote ++ CR endfor else messagebox("ok error", "File not opened", "FILE plugin error #1") quit endif file.close(fh) if(Comms == 0) do Str = "File " ++ Source ++ " seems to contain no file comments!" messagebox("ok warning", Str, "CopyComment Script") vec.destroy(v) vec.destroy(w) vec.destroy(N) quit elseif(Comms == 1) do i = 0 elseif(Comms > 1) do Str = pickstring(Result, "Pick a comment to copy for file " ++ Name) if(not _pickedline_) do vec.destroy(v) vec.destroy(w) vec.destroy(N) quit endif i = _pickedline_ - 1 endif file.delete(Source) Str = w[i] if(ini.check_exists(Config, "Options", "Delimiter") == 3) Delim = ini.get(Config, "Options", "Delimiter") if(not Where) do vec.insert(v, Comms, ifelse(index(Name, " "), Quote ++ Name ++ Quote, Name)) vec.insert(w, Comms, Str) elseif(Where == "&Before") do w[Ind] = Str ++ Delim ++ w[Ind] elseif(Where == "&After") do w[Ind] = w[Ind] ++ Delim ++ Str elseif(Where == "&Instead") do w[Ind] = Str endif if(not Move && ini.check_exists(Config, "Options", "Move") == 3) Move = ini.get(Config, "Options", "Move") if(Move == 1) do vec.delete(v, i) vec.delete(w, i) elseif(Move == 2) do Str = "Delete comment " ++ OpQuote ++ w[i] ++ ClQuote ++ " of file " Str = Str ++ v[i] ++ "?" if(messagebox("yesno question", Str, "Move or copy comment") == 6) do vec.delete(v, i) vec.delete(w, i) endif endif if(ini.check_exists(Config, "Options", "Sort") == 3) vec.doublesortstring(v, w) fh = file.open(Source, "w") if(fh <= 0) do messagebox("ok error", "File not opened", "FILE plugin error #2") quit endif if(ini.check_exists(Config, "Options", "NotComments") == 3) do Str = ini.get(Config, "Options", "NotComments") else Str = 0 endif if(Str == 1) do for(i = 0; i < NotComms; i = i + 1) file.writeline(fh, N[i]) endfor file.writeline(fh, CR) endif for(i = 0; i < vec.length(v); i = i + 1) file.writeline(fh, v[i] ++ " " ++ w[i]) endfor if(Str == 0) do file.writeline(fh, CR) for(i = 0; i < NotComms; i = i + 1) file.writeline(fh, N[i]) endfor endif file.close(fh) vec.destroy(v) vec.destroy(w) vec.destroy(N) Source = win.handle("c=TTOTAL_CMD") win.sendmessage(Source, 0x400+51, 540, 0)