Generation

fix invalid codeMon, 05 Jun 2023

procedure Tini.ImportToTreeView(TreeView: TTreeView); var I, Last: TTreeViewItem; ImportData, S: ISuperObject; begin // Проверка наличия файла var FilePath := TPath.GetDocumentsPath + PathDelim + 'tw_resource.json'; if not FileExists(FilePath) then begin Exit; end; // Проверка наличия TreeView if not Assigned(TreeView) then begin Exit; end; // Загрузка данных из файла ImportData := TSuperObject.ParseFile(FilePath, True, False); if not Assigned(ImportData) then begin Exit; end; TreeView.Clear; Last := nil; // Инициализация переменной Last for S in ImportData['Data'] do begin I := TTreeViewItem.Create(nil); I.Text := S.S['text']; I.TagString := S.S['str']; I.Hint := S.S['color']; case S.I['level'] of 1: begin TreeView.AddObject(I); Last := I; end; else begin while (Assigned(Last) and (S.I['level'] <= Last.Level)) do Last := Last.ParentItem; if Assigned(Last) then Last.AddObject(I) else TreeView.AddObject(I); Last := I; end; end; end; TreeView.ExpandAll; end;

- remove invalid code:

Want to kickstart your project?Use the new AI Studio to create your code