rejetto forum

numbers files, folders, links ....

Mars · 2 · 1357

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2039
    • View Profile
There are at present three variables [%number-folders%,%number-files%,%number-links%]which count(record) the various types (see %item-type% in build 236) of elements with a total of %numbers% , but there was nothing to index each of these elements in the category, a small addition in the code of delphi and the problem is resolved with  %item-number%:

Every time an element is added to the list, he is associated with him an index of position

by example inside of template:

[folder=link=file]
%item-number% / {.switch|%item-type%||folder|%number-folders%|file|%number-files%|link|%number-links%.}


 Rejetto: if you are not convinced by %item-number%, I propose you %item-type-idx%

Quote
  procedure handleItem(f:Tfile);
  var
    type_, s, url, fingerprint, itemFolder: string;
    nonPerc: TStringDynArray;
    number_: integer;    //add by mars
  begin
 ......
  // select appropriate template
  if f.isLink() then
    begin
    s:=linkTpl;
    inc(numberLinks);
    number_:=numberLinks;    //add by mars
    type_:='link';
    end
  else if f.isFolder() then
    begin
    s:=folderTpl;
    inc(numberFolders);
    number_:=numberFolders;      //add by mars
    type_:='folder';
    end
  else
    begin
    s:=diffTpl.getTxtByExt(ExtractFileExt(f.name));
    if s = '' then s:=diffTpl.getTxtByExt(ExtractFileExt(f.name));
    if s = '' then s:=fileTpl;
    inc(numberFiles);
    number_:=numberFiles;        //add by mars
    type_:='file';
    end;

  addArray(md.table, [
    '%item-type%', type_,
    '%item-number%', inttostr(number_)   
  //add by mars
  ]);

  s:=xtpl(s, nonPerc);
  md.f:=f;
  tryApplyMacrosAndSymbols(s, md, FALSE);
  fast.append(s);
  end; // handleItem

nécessaire? je l'utilise dans le mode page et cela évite bien des macros 'if' et des compteurs.. ;)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13309
    • View Profile