mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2003
Posts: 15
Z
ZeBoxx Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2003
Posts: 15
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.


__________
ZeBoxx
¯¯¯¯¯¯¯¯¯¯
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Consecutive spaces and mirc for ya smirk


$maybe
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
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..


Saturn, QuakeNet staff
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
$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).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Jun 2003
Posts: 15
Z
ZeBoxx Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2003
Posts: 15
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


__________
ZeBoxx
¯¯¯¯¯¯¯¯¯¯
Joined: Feb 2003
Posts: 31
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Feb 2003
Posts: 31
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.

Joined: Jun 2003
Posts: 15
Z
ZeBoxx Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2003
Posts: 15
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 )


__________
ZeBoxx
¯¯¯¯¯¯¯¯¯¯
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.

Joined: Jun 2003
Posts: 15
Z
ZeBoxx Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2003
Posts: 15
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


__________
ZeBoxx
¯¯¯¯¯¯¯¯¯¯

Link Copied to Clipboard