rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on June 03, 2009, 09:13:37 PM

Title: question to rejetto about macro exec ??
Post by: Mars on June 03, 2009, 09:13:37 PM
I shall like that we explain me the utility to put two macrodequote in the procedure exec_()

Do you use this syntax,

{.exec|{:c:\program files\notepad++.exe:}|{:hfs.ini:}.}

or rather this one?

{.exec|"c:\program files\notepad++.exe"|"hfs.ini".}

It is not the same dequote that it is necessary to use in that case

Quote
procedure exec_();
  var
    s: string;
  begin
  s:=dequote(par(1));
  if fileOrDirExists(s) then
    s:=quoteIfAnyChar(' ', s)
  else
    if unnamedPars < 2 then
      s:='';
  if parExist(['out']) or parExist(['timeout']) then
    try
      spaceIf(captureExec(dequote(p)+nonEmptyConcat(' ', s), s, parI('timeout',2)));
      setVar(parEx('out'), s);
    except end
  else
    spaceIf(exec(dequote(p), s))
  end; // exec_



function dequote(s:string; quoteChars:TcharSet=['"']):string;
begin
if (s > '') and (s[1] = s[length(s)]) and (s[1] in quoteChars) then
  result:=copy(s, 2, length(s)-2)
else
  result:=s;
end; // dequote

It is going to need of crowned arguments to convince me of the opposite here (http://boitam.eu/boitam.eu.swf)  :)
Title: Re: question to rejetto about macro exec ??
Post by: rejetto on June 04, 2009, 05:22:21 PM
i don't remember the reason, but i guess it was to allow something like
{.exec|{:cmd.exe /c dir|grep w:}|out=#x.}{.^#x.}
;)
Title: Re: question to rejetto about macro exec ??
Post by: Mars on June 04, 2009, 07:37:24 PM
it is time to change syntax to

{.exec|cmd="cmd.exe"|pars="/c dir{:|:}grep w"|out=#x|timeout=xx.}{.^#x.}

Here is a compromise with macrodequote and the necessity of dequote
Quote
  procedure exec_();
  var
    s: string;
  begin
  s:=dequote(macroDequote(par(1,'pars')));
  if fileOrDirExists(s) then
    s:=quoteIfAnyChar(' ', s)
  else
    if unnamedPars < 2 then
      s:='';
  if parExist(['out']) or parExist(['timeout']) then
    try
      spaceIf(captureExec(dequote(macroDequote(par(0,'cmd')))+nonEmptyConcat(' ', s), s, parI('timeout',2)));
      setVar(parEx('out'), s);
    except end
  else
    spaceIf(exec(dequote(macroDequote(par(0,'cmd'))), s))
  end; // exec_

 then it is possible to use
{.exec| cmd={:"cmd.exe":} | pars={:"/c dir|grep w":} |out=#x|timeout=xx.}{.^#x.}

or
{.exec| cmd=cmd.exe | pars=/c dir{:|:}grep w[/color] |out=#x|timeout=xx.}{.^#x.}
 

And still
{.exec|cmd.exe|{:/c dir|grep w:} |out=#x|timeout=xx.}{.^#x.}

a new build 243 and then silentpliz will be happy to translate  :D ;)
Title: Re: question to rejetto about macro exec ??
Post by: rejetto on June 07, 2009, 09:23:13 PM
this syntax you suggest doesn't seem to be better
Title: Re: question to rejetto about macro exec ??
Post by: bacter on June 07, 2009, 10:07:21 PM
There seems also to be a problem with exec parsing order with comments. When developping/debugging macros, i often outcomment some block of code. But in the following example the exec is executed:

Code: [Select]
{.comment|
<b>exec and this should not be displayed - and is not displayed</b><br />
{.exec|{:c:\Archivos de programa\Notepad++\notepad++.exe:}|{:hfs.ini:}.}
.}
Title: Re: question to rejetto about macro exec ??
Post by: rejetto on June 07, 2009, 10:30:10 PM
eh, i'm sorry but this is just not possible.
macros are always executed from inner to outer.
"exec" is run before "comment".
there's nothing "comment" can do for it.
the only tool we have for delaying execution is {:quotings:}.