rejetto forum

Some macros very useful

Mars · 2 · 3353

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
  if ansiContainsText(name, 'folder') and not ansiContainsText(name, 'comment') then
    result:=macroQuote(result);
  end; // handleSymbol

 var
  i: int64;
  j: integer;        // add by mars
  r: Tdatetime;
  s: string;
begin
try
  try
    assert(assigned(cbData), 'cbMacros: cbData=NIL');
    md:=cbData;

.......

    if name = 'filename' then
      result:=extractFileName(p);

    if name = 'filepath' then          //add by mars
      result:=extractFilepath(p);


......

    if pars.count < 2 then exit; // from here, only macros with at least 2 parameters

    if name = 'first not empty' then         //add by mars
      begin
      for j := 0 to pars.count - 1 do
        if trim(pars.Names[j])='notrim' then pars[j]:=pars.ValueFromIndex[j]  //pars[j] is not trimed and 'notrim=' is removed from pars[j]
          else pars[j]:=par(j);                                                             //pars[j] is trimed
      result:=first(listToArray(pars));
      end;


    if name = 'while' then
      while_();


USAGE:

{.filepath|A}    where A is a path
an example to return the path without the / at the end
{.substring||-1|{.filepath|%item-resource%.}.}

one usage can be
[upload completed]
{.mkdir|{.filepath|%item-resource%.}%user%.}
{.move|%item-resource%|{.filepath|%item-resource%.}%user%.}


{.first not empty|A|B|C|.........|XX.}    or   {.first not empty|A|B| notrim =C|....|notrim=Z|.....|XX.}
every A,B,C,....,XX is trimed  except if you use the command 'notrim=' whit or without space  ('  notrim ='
an example of macro is given by the return of the second parameter
{.add to log|first not empty:'{.first not empty| |   notrim  =         | | |mars.}'.}

one usage can be
{first not empty|%user%|Guest.} at the place of {.if|%user%|%user%|Guest.}


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
ok {.filepath.}

{.first not empty.} = {.or.}