mIRC Homepage

$findfile command-to-run $1- swallows spaces

Posted By: ZeBoxx

$findfile command-to-run $1- swallows spaces - 21/12/05 04:25 PM

create a file called "hello world.txt" (two spaces, in case the board eats them) in your mirc dir.

//echo -s $findfile($mircdir,hello*world.txt,1)
result is the filename with a single space

//echo -s $replace($findfile($mircdir,hello*world.txt,1),$str($chr(32),2),_SPACESPACE_)
result is the filename with the two spaces replaced by "_SPACESPACE_" - e.g. "hello_SPACESPACE_world.txt"

//echo -s $findfile($mircdir,hello*world.txt,1,echo -s -> $replace($1-,$str($chr(32),2),_SPACESPACE_))
result is the filename with a single space
I had expected $1- to contain the actual filename with spaces intact, so that the $replace would allow me to 'tag' it as being a filename with consecutive spaces. Apparently not.
Posted By: Mpdreamz

Re: $findfile command-to-run $1- swallows spaces - 21/12/05 05:51 PM

Consecutive spaces and mirc for ya smirk
Posted By: Sat

Re: $findfile command-to-run $1- swallows spaces - 21/12/05 06:07 PM

Unfortunately it's quite in line with other cases where mIRC tokenizes (to $1-) whatever it's going to pass to a piece of code, including for example input text in the "on INPUT" event. It would be great if the behaviour of $1- were changed in these cases..
Posted By: starbucks_mafia

Re: $findfile command-to-run $1- swallows spaces - 21/12/05 06:16 PM

$1- is a set of space delimited tokens, and mIRC doesn't support null tokens. It'd take a pretty fundamental (and largely non-backwards compatible) change to the scripting engine for $1- to act the way you want.

As far as $findfile() goes you can simply use $findfile().shortfn and $1- will contain the short filename and thus work correctly. You can use $longfn($1-) if/when you want to display the filename anywhere (it'll still have the consecutive spaces missing when displayed but it's better than not working at all).
Posted By: ZeBoxx

Re: $findfile command-to-run $1- swallows spaces - 22/12/05 03:10 PM

Quote:
As far as $findfile() goes you can simply use $findfile().shortfn

Yeah, that's what I'm using now.

I guess it makes sense that $1- would indeed swallow spaces in terms of generic use. However, as the number of technical tokens in $findfile is always 0 ($null) or 1, and never more, I had somewhat expected it to keep things intact.

Ah well, here's to hoping that Khaled does make the significant code change. I'll leave that discussion to the script language thread though smile
Posted By: Jinx_Dojo

Re: $findfile command-to-run $1- swallows spaces - 21/01/06 12:55 PM

I can see shortfn working for most situations... but wouldn't it be possible to create another prop for $findfile and $finddir like .preservespaces? They are really the only 2 functions in their class. The only other commands I can think of which would really need whitespace preservation are /rename, /write, and /del. Eh, just a thought. I'm sure we'll live with shortfn, just suprised alternatives couldn't be made without reworking so much into non-backward-compatible code.
Posted By: ZeBoxx

Re: $findfile command-to-run $1- swallows spaces - 03/02/06 10:00 PM

Unfortunately, shortfn won't help entirely either. Let's say you want to make sure you're copying files from "c:\Program Files\" to "d:\Program Files\". However, drive D has another folder that was created before "Program Files", called "d:\Program Data".

c:\Program Files\ = C:\PROGRA~1
d:\Program Files\ = D:\PROGRA~2
d:\Program Data\ = D:\PROGRA~1
So when copying from C:\PROGRA~1 to D:\PROGRA~1, the files end up in the wrong place.

I ended up using COM instead. Highly annoying, but until these limitations are lifted, what can one do - and, I suppose, expect from an application that is really a chat app smile
( Sure, I used it to parse FTP uploads, create thumbnails, and serve them to the web. Sure, I used it to fine-tune my WiFi to get the best signal on 4 machines throughout a single location. Sure, I used it to MAKE MY COFFEE every morning (by printing to a printer, on a timer, the printer head bumps into the on/off switch) - no, no joke. Yes, short-lived :P But in the end, I suppose it's still 'a chat app'. Shame smile )
Posted By: DaveC

Re: $findfile command-to-run $1- swallows spaces - 03/02/06 10:22 PM

Quote:

c:\Program Files\ = C:\PROGRA~1
d:\Program Files\ = D:\PROGRA~2
d:\Program Data\ = D:\PROGRA~1
So when copying from C:\PROGRA~1 to D:\PROGRA~1, the files end up in the wrong place.


You know your ment to get the shortfn using a function, not just guess what it is, no wonder it might fail assuming ~1, even my c:\program files isnt that!

Nice use of the printer by the way.
Posted By: ZeBoxx

Re: $findfile command-to-run $1- swallows spaces - 04/02/06 08:21 PM

Quote:
You know your ment to get the shortfn using a function, not just guess what it is, no wonder it might fail assuming ~1, even my c:\program files isnt that!

Yep, I know - not assuming anything. Problem is that this means that you need to do many additional checks to not just get the source file shortfn, but also the destination dir shortfn - and that's the easy part wink

Quote:
Nice use of the printer by the way.

Thanks! It (DeskJet 500, b/w) was just laying around smile Not as cool as making a Scanjet 3C play "Fuer Elise".. makes me sorta, but not really, wish I'd kept that thing wink
© 2022 mIRC Discussion Forums