So I have this marvellously debugged wkp doing exactly what I want, with one problem. When I transfer my wkp to my gig computer, it loads up all wrong, turns off a bunch of midi interfaces, and crashes the first time I try to load a file.
I understand now that this is because of memory leaks, and I'm trying to go through all my scripts looking for issues. The one thing that Olivier has mentioned is running off the end of an array. But I do not know what other practices might be a problem, and any further information on this would be welcome.
I will start off with a function that I imagine is an issue. I am paging through this list, but it looks like since I may remove an item partway through the process, I could try to address an element beyond the end of the list. Is this correct? I assume that the function does not stop as soon as it gets to the result line. If not, maybe this is fine. It still seems like bad form, so I am going to rewrite it:
Code: Select all
//// returns the data associated with a tag,
//// and removes the line containing the tag from the list
function CutLineForTag(TAG: string; list: tStringlist): string;
var line: string;
var i: integer;
begin
for i := 0 to (list.count - 1) do
begin
//debug('checking line:' + intToStr(i) + ': ' + list.getStrings(i));
line := list.getStrings(i);
if stringsMatch(TAG, getTagForLine(line)) then
begin
result := getDataForLine(line);
list.delete(i);
debug('stripped ' + tag + ', value: ' + getDataForLine(line));
end;
end;
end;THANKS ALL!
=eric
