rejetto forum
Software => HFS ~ HTTP File Server => Programmers corner => Topic started 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
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) :)
-
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.}
;)
-
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
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 ;)
-
this syntax you suggest doesn't seem to be better
-
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:
{.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:}.}
.}
-
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:}.