rejetto forum

question to rejetto about macro exec ??

Mars · 6 · 5150

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
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  :)
« Last Edit: June 03, 2009, 10:05:06 PM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
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.}
;)


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
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 ;)
« Last Edit: October 08, 2013, 04:59:46 PM by Mars »


Offline rejetto

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

Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
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:}.}
.}
your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
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:}.