mIRC Home    About    Download    Register    News    Help

Print Thread
$findfile() trims whitespaces from filenames #214587 08/08/09 11:52 PM
Joined: Aug 2008
Posts: 14
D
Dankirk Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Aug 2008
Posts: 14
Reproduction with following:

Create a file with some whitespaces in its name. use $findfile to find it, for example:
$findfile(,,,echo -a $count($1-,$chr(32)))

This echoes number of spaces in found filename(s).

Running mIRC 6.35 on Vista 32bit.

Re: $findfile() trims whitespaces from filenames [Re: Dankirk] #214596 09/08/09 04:43 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
$findfile is not trimming any spaces, the fact that the file is located in $1- for scripting purposes means it's already been tokenized by spaces and therefore the multiple spaces are lost. This is unfortunately a reality of how parameter tokenization works inside mIRC.

One possibility is that mIRC could stop tokenizing filenames by $chr(32) and use $chr(44) or some other token instead (perhaps an illegal file character), that way the entire file would be contained in $1. Another thing mIRC could do is create a special identifier (like $findfilematch or the \1 in $regsubex).

Until that change is made, you'll have to loop through $findfile(dir,*,%i) to get the accurate filename. You can see that $findfile is not actually trimming spaces because this usage will maintain all spaces.

Example:

Create "test 1 2 3.txt" in your $mircdir and use
//echo -a $count($findfile($mircdir,test*.txt,1), $chr(32))

That said, there's not much you can do with these filenames inside mIRC, the second you use them outside an identifier the extra space will be lost. This basically means you will not be able to perform any file operations on these files (/write, /rename, /remove) except $read.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: $findfile() trims whitespaces from filenames [Re: Dankirk] #214599 09/08/09 11:43 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
Use $findfile().shortfn

Re: $findfile() trims whitespaces from filenames [Re: hixxy] #214605 09/08/09 02:19 PM
Joined: Aug 2008
Posts: 14
D
Dankirk Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Aug 2008
Posts: 14
Thanks for these clarifications and workarounds.