rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on May 17, 2009, 11:20:49 PM

Title: Some macros very useful
Post by: Mars on May 17, 2009, 11:20:49 PM
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.}
Title: Re: Some macros very useful
Post by: rejetto on May 18, 2009, 09:52:31 AM
ok {.filepath.}

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