|
Joined: Mar 2008
Posts: 44
Ameglian cow
|
OP
Ameglian cow
Joined: Mar 2008
Posts: 44 |
hi. $findfile() doesn't seem to be finding the file with multiple words in this case. in the following code.. %books.folder echoes to -> C:\Program Files\mIRC 6.35\Books\
%bookname.tok to -> second book
*second book*.txt <-- that's $+(*,%bookname.tok,*,.txt) - echoed just before the $findfile line
the actual filename is = The Second Book xyz.txt This is the $findfile line var %book.path = $findfile($+(",%books.folder,"),$+(*,%bookname.tok,*,.txt),1) This problem seems to appear only with multiple words. For example if %bookname.tok = second the whole script works fine and in all single words i tried so far it works fine. thankyou ~
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Your script isn't evaluating %bookname.tok before appending the additional information, so your script is literally seeing $+(*,%bookname.tok,*,.,txt) as *%bookname.tok*.txt You need to double evaluate the string, the same way as you would double evaluate a compound variable. Use $($+(*,%bookname.tok,*,txt),2) in the $findfile
|
|
|
|
Joined: Mar 2008
Posts: 44
Ameglian cow
|
OP
Ameglian cow
Joined: Mar 2008
Posts: 44 |
hi Russel.. think you misunderstood some of what i wrote. I was just posting the echoed values
$+(*,%bookname.tok,*,.txt) <-- the echo for that is *second book*.txt - which is correct.
i had tried $eval before & it doesn't help besides if that was the problem then single word wildcards too, wouldn't have functioned proper with $findfile. the script & $findfile() works fine for all single word wildcards i.e if %bookname.tok = singleword if %bookname.tok = two words <-- can't get this to work
thanks ~ thanks
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
OK, and you're right I did partially misunderstand. Try putting quotes around the multiple words, like you did for the %books.folder variable. $findfile($qt(%books.folder),$+(*,$qt(%bookname.tok),*,.txt),1)
|
|
|
|
Joined: Mar 2008
Posts: 44
Ameglian cow
|
OP
Ameglian cow
Joined: Mar 2008
Posts: 44 |
Russel, just tried... doesn't help
thanks! ~
|
|
|
|
Joined: Mar 2008
Posts: 44
Ameglian cow
|
OP
Ameglian cow
Joined: Mar 2008
Posts: 44 |
Russel, just tried... doesn't help
thanks! ~
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Works fine for me, e.g.: alias findtest {
var -s %books.folder = $mircdir, %bookname.tok = second book
echo -a files: $findfile(%books.folder,$+(*,%bookname.tok,*.txt),0)
var -s %book.path = $findfile(%books.folder,$+(*,%bookname.tok,*.txt),1)
echo -a creating now "A second book.txt" in %books.folder
write -c $qt(%books.folder $+ A second book.txt)
echo -a files: $findfile(%books.folder,$+(*,%bookname.tok,*.txt),0)
var -s %book.path = $findfile(%books.folder,$+(*,%bookname.tok,*.txt),1)
remove $qt(%books.folder $+ A second book.txt)
}
returns like expected: * Set %books.folder to D:\Programme\mirc\ * Set %bookname.tok to second book files: 0 * Set %book.path to creating now "A second book.txt" in D:\Programme\mirc\ files: 1 * Set %book.path to D:\Programme\mirc\A second book.txt * Removed 'D:\Programme\mirc\A second book.txt' Edit: removed the unnecessary $qt(), they're required only in the write / remove commands that have no "delimiting" commas
Last edited by Horstl; 01/02/09 06:24 AM.
|
|
|
|
|