mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Both $findfile and $finddir can see consecutive spaces in the path parameter, but are ignoring consecutive spaces in the wildfile parameter, causing it to also return all filenames containing only 1 space. Assuming there's at least 1 name having 1 space and at least 1 name having consecutive spaces:

//var %a $+(*,$str($chr(32),2),*) | echo -a %a $len(%a) $findfile(c:\path\,%a,0,echo -a $parms)

//var %a $+(*,$str($chr(32),2),*) | echo -a %a $len(%a) $findfile(c:\path\,* $chr(32) $+ *,0,echo -a $parms)

I know the output can see the spaces because $regex can filter the individual lines but not the grand total.

//var %a $+(*,$str($chr(32),2),*) | echo -a %a $len(%a) $findfile(c:\path\,%a,0,if ($regex($parms,\s\s)) echo -a $parms)

Joined: Dec 2002
Posts: 5,412
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,412
Thanks for your bug report. This is a known issue. Spaces, such as multiple consecutive, leading, or trailing spaces, are rarely preserved in the script parser. The issue is not only limited to the script parser, it applies to many features, where extra spaces are removed from parameters.

While it is possible to preserve spaces using some combinations of identifiers, that is simply exploiting aspects of the scripting language that happen to work that way. If it works for you in one context, or one identifier, that does not mean that it will work in another one.

There is little that can done other than rewriting the script parser from the ground up to preserve spaces in commands and their parameters, including the addition of quote "" support to delimit strings, and so on, which would likely lead to the breaking of scripts in many ways.

Joined: Dec 2002
Posts: 5,412
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,412
I looked through the $findfile() code again and there is a point where extra spaces are removed from the wildcard parameter due to parsing the multiple wildcard ; separator, which itself allows spaces between each wildcard and the ; separator. This can be changed so that only spaces surrounding each wildcard are removed, which should preserve internal spaces. Unless anyone can see a backwards compatibility issue with this, this change will be in the next version.


Link Copied to Clipboard