static Config = env("WINDIR") ++ "\wincmd.ini" local hwnd = win.handle("c=TTOTAL_CMD") local TotalPath = file.folder(win.exepath(hwnd)) local Total = TotalPath ++ "\" ++ ifelse(arg(2), arg(2), win.exename(hwnd)) ++ ".exe" local Path = TotalPath ++ "\inis\" local Backup = Path ++ "Backup.ini" local j, k, OneSec, OneKey, NewKeys, MainKeys, Counter, NewValue, MainValue, Name local MainSections, MainNumber, TempConf static I = ".ini" static IMS = "IniManager Script" ini.error_dialog_off() v = vec.createfromwords("left right lefttabs righttabs") if(v <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error #1") quit endif if(arg(1) == "b") do file.copy(Config, Backup) quit elseif(arg(1) == "r") do file.copy(Backup, Config) win.sendmessage(hwnd, 0x400+51, 24340, 0) for(j = 0; j < 4; j++) ini.delete_section(Backup, v[j]) ini.copy_section(v[j], Backup, v[j], Config) endfor do(Total) quit elseif(arg(1) == "s") do jump Save elseif(arg(1) == "c") do jump Copy elseif(arg(1) == "n") do jump New elseif(arg(1) == "i") do jump Insert endif Name = arg(1) TempConf = miscplugin.tempfilename(Name, Path) ++ I Name = Path ++ Name ++ I MainSections = ini.enum_sections(Config) MainNumber = line(MainSections, 0) for(j = 1; j <= MainNumber; j++) OneSec = line(MainSections, j) MainKeys = ini.enum_keys(Config, OneSec) Counter = line(MainKeys, 0) if(ini.check_exists(Name, OneSec) == 2) do for(k = 1; k <= Counter; k++) OneKey = line(MainKeys, k) if(ini.check_exists(Name, OneSec, OneKey) == 3) do NewValue = ini.get(Name, OneSec, OneKey) else NewValue = ini.get(Config, OneSec, OneKey) endif ini.set(TempConf, OneSec, OneKey, NewValue) endfor else ini.copy_section(OneSec, Config, OneSec, TempConf) endif endfor for(j = 0; j < 4; j++) ini.delete_section(TempConf, v[j]) ini.copy_section(v[j], Name, v[j], TempConf) endfor do(Total, "/n /i=" ++ TempConf) quit @Save win.sendmessage(hwnd, 0x400+51, 580, 0) MainSections = ini.enum_sections(Backup) MainNumber = line(MainSections, 0) Name = inputcancel("Input new INI file name") Name = Path ++ Name ++ I flag set 1 for(j = 1; j <= MainNumber; j++) OneSec = line(MainSections, j) if(ini.check_exists(Config, OneSec) == 2) do MainKeys = ini.enum_keys(Backup, OneSec) Counter = line(MainKeys, 0) for(k = 1; k <= Counter; k++) OneKey = line(MainKeys, k) if(ini.check_exists(Config, OneSec, OneKey) == 3) do NewValue = ini.get(Config, OneSec, OneKey) MainValue = ini.get(Backup, OneSec, OneKey) if(NewValue != MainValue) do ini.set(Name, OneSec, OneKey, NewValue) flag clear 1 endif endif endfor endif endfor if(pproflag(1)) messagebox("ok warning", "No changes detected", "INI file not created") for(j = 0; j < 4; j++) ini.delete_section(Backup, v[j]) ini.copy_section(v[j], Config, v[j], Name) endfor quit @Copy win.sendmessage(hwnd, 0x400+51, 580, 0) Name = file.listfiles(Path ++ "*" ++ I) v = vec.createfromlines(Name, 1) if(v == 0) do messagebox("ok error", "Vector not created", "VEC plugin error #2") quit endif Counter = vec.length(v) vec.insert(v, Counter, Config) Counter++ if(TempConf) vec.insert(v, Counter, TempConf) Name = vec.makelines(v) local From = pickstring(Name, "Select FILE to copy FROM") if(not From) do quit MainSections = ini.enum_sections(From) NewValue = "Select SECTION in file '" ++ From ++ "' to copy FROM" OneSec = pickstring(MainSections, NewValue) if(not OneSec) quit NewValue = "Select FILE to copy section '" ++ OneSec ++ "' TO" local To = pickstring(Name, NewValue) if(not To) quit ini.copy_section(OneSec, From, OneSec, To) quit @New TempConf = miscplugin.tempfilename() ++ I do(Total, "/n /i=" ++ TempConf) quit @Insert local Point, From, To, Dir local Str = "~Dir=Copy direction (Source > Target)??|[Dirmenu] > [user]|[user] > [Dirmenu]," Str ++= "From=Source item number to copy (FROM),To=Source item number to copy (TO)," Str ++= "Point=Target section number to copy AFTER" Name = inputdialog(Str, "Copy Keys from One Section to Another") if(not Name) quit v[0] = "user" v[1] = "Dirmenu" local Source = v[not Dir] local Target = v[Dir] MainKeys = ini.enum_keys(Config, Target) for(j = line(MainKeys, 0); j >= 0; j--) Name = line(MainKeys, j) NewKeys = ini.get(Config, Target, Name) Counter = 0 NewValue = "" for(k = 0; k <= length(Name); k++) MainValue = Name[k] if(miscplugin.is_int(MainValue)) do Counter ++= MainValue else NewValue ++= MainValue endif endfor if(Counter < Point) do break else MainNumber = Counter + To - From + 1 ini.set(Config, Target, NewValue ++ MainNumber, NewKeys) endif endfor MainKeys = ini.enum_keys(Config, Source) for(j = 1; j <= line(MainKeys, 0); j++) Name = line(MainKeys, j) NewKeys = ini.get(Config, Source, Name) Counter = 0 NewValue = "" for(k = 0; k <= length(Name); k++) MainValue = Name[k] if(miscplugin.is_int(MainValue)) do Counter ++= MainValue else NewValue ++= MainValue endif endfor if(Counter >= From && Counter <= To) do MainNumber = Counter - From + Point ini.set(Config, Target, NewValue ++ MainNumber, NewKeys) endif if(Counter > To) break endfor