Thank you mars, I have already found a workaround to do what I need.
My question is not what the delphi code does, but what the macro should do in the case if frompattern or topattern are not found!
If rejetto thinks in case that a pattern is not found substring should return the whole string, it's ok. But if he agrees that it would be more logical that when patterns are defined and not found substring should return nothing, then it would be a bug and require some modification like this:
i:=pos(pars[0],s);j=posEx(pars[1],s,max(1,i)+1);
if (i=0 & length(pars[1])>0) | j=0 & length(pars[2])>0) then .. return void string
else i:=max(1,i); if j=0 then j:=length(s+1) .....return string from i to j of s