It was a copy-paste mistake. Solved it. Done Sorry but I don't understand how. 'f' is IwbFile so 'copyfile' must be IwbFile too. Am I wrong? Done And about troubleshooting. Looks like the only problem is with "Process" function. I don't get even "Start matching names" message. Here is my code now
unit userscript;
var
s1, slPath: string;
i: integer;
f, ovrec, copyfile: IInterface;
function Initialize: integer;
begin
// initialize your stuff here
// use InputBox to accept user input for filename, then use a loop to find that file and store it in a variable. I do this in several of my scripts.
// use a looping InputBox until the input is empty to add paths the user wants to copy things from to a stringlist: slPaths
s1 := InputBox('File','Enter the name of the file containing the record you want to copy an element from, including the file extension','Skyrim.esm');
for i := 0 to FileCount - 1 do
begin
f:= FileByIndex(i);
AddMessage('Checking file '+GetFileName(f));
if SameText(s1, GetFileName(f)) then
begin
copyfile := f;
AddMessage('File is '+GetFileName(copyfile));
Break;
end;
end;
slPath := InputBox('Path', 'Enter path you want to copy', '');
AddMessage('Path is '+slPath);
//here i have not array of pathes but only one. That's what i need
end;
function Process(e: IInterface): integer;
begin
AddMessage('Start Process function');
for i := 0 to OverrideCount(e) - 1 do
begin
AddMessage('Start matching names');
if GetFileName(GetFile(OverrideByIndex(e, i))) = GetFileName(copyfile) then begin
AddMessage('Names match');
ovrec := OverrideByIndex(e, i);
AddMessage('ovrec assigned: '+GetElementEditValues(ovrec, 'EDID'));
Break;
end;
end;
wbCopyElementToRecord(e, ElementByPath(ovrec, slPath), True, True);
//changeg first boolean to False because it is referred as "aAsNew"... And what i need is to replace old record (weight or price), not to add something new.
//doesn't work both with True of False anyway
end;
end.
I hope I don't bore you too much matortheeternal I'm just really limited with my time, and this script is all I need to continue development of my mod (which I'm still intending to continue). So I just have to hope that you consider helping me with it... And of course I'll understand if you don't want to bother with it.