Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- Test GetChildRecords
- }
- unit userscript;
- const
- saveRecords = true;
- maxRecordsToSave = 10000;
- procedure SaveRecordNames(var lst: TList; fn: string);
- var
- sl: TStringList;
- i: Integer;
- begin
- sl := TStringList.Create;
- for i := 0 to Pred(lst.Count) do
- sl.Add(Name(ObjectToElement(TObject(lst[i]))));
- AddMessage(' Saved to '+fn);
- sl.SaveToFile(fn);
- sl.Free;
- end;
- procedure TestGetChildRecords(f: IInterface; gsig, sig: string);
- var
- g: IInterface;
- t: TDateTime;
- lst: TList;
- begin
- AddMessage(Format('Searching file %s for records matching %s in group %s', [GetFileName(f), sig, gsig]));
- g := GroupBySignature(f, gsig);
- if not Assigned(g) then begin
- AddMessage(' Group not found! Skipping.');
- exit;
- end;
- t := Now;
- lst := TList.Create;
- GetChildRecords(g, sig, lst);
- AddMessage(Format(' Found %d records in %0.3fs', [lst.Count, (Now - t)*86400]));
- if saveRecords and (lst.Count <= maxRecordsToSave) then
- SaveRecordNames(lst, Format('%s-%s-%s.txt', [GetFileName(f), gsig, sig]));
- lst.Free;
- AddMessage(' ');
- end;
- function Initialize: integer;
- var
- f: IInterface;
- begin
- f := FileByIndex(0);
- TestGetChildRecords(f, 'CELL', 'REFR');
- TestGetChildRecords(f, 'CELL', 'ACHR');
- TestGetChildRecords(f, 'CELL', 'NAVM');
- TestGetChildRecords(f, 'WRLD', 'REFR');
- TestGetChildRecords(f, 'WRLD', 'ACHR');
- TestGetChildRecords(f, 'WRLD', 'NAVM');
- TestGetChildRecords(f, 'DIAL', 'INFO');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment