|
Joined: Dec 2002
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2002
Posts: 5 |
Here's the code
on 1:TEXT:~test:#: { if ($exists(c:\mirc\files\ $+ $nick $+ .txt) == $true) { msg $chan Exists } | else { msg $chan does not exist } }
It always returns "does not exist". However, when I change $+ $nick $+ .txt to cyter.txt, it returns "Exists". I added a message to show what it was getting in the exist, and it told me c:\mirc\files\cyter.txt Any ideas what is wrong? I've asked several other people, but they couldn't figure out what was wrong.
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
on 1:TEXT:~test:#: {
if ($exists($+(c:\mirc\files\,$nick,.txt))) msg $chan Exists
else msg $chan does not exist
} You might also try using $mircdir or $scriptdir.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Dec 2002
Posts: 271
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 271 |
hmmm, i have always used "$isfile" to check if a file is there or not...
if ($isfile(thispath\thisfile)) { echo -a yes it is there }
simple example, lol
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
You could also use $file(filename) as well. It will return $null if it is not found or 0 if the file is empty. You could even test for both conditions if you wanted to.
on *:TEXT:!exists*:#:{
if ($file($+(",$mircdir,$$2-,.txt")) == $null) msg $chan $2 was not found.
elseif ($file($+(",$mircdir,$2,.txt")) == 0) msg $chan $2 was found, but it's an empty file.
else msg $chan $2 was found!
} You could also use: msg $chan $findfile(C:\,$+(",$2-,.txt"),0,msg $chan $nopath($1-) was found in $nofile($1-)) matches found for $2- but that's getting a little out of hand, don't you agree?
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Dec 2002
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2002
Posts: 5 |
I appreciate the quick responses, and I tried out the $isfile and the $exists Hammer showed.
However, it still said no file exists. Once I changed the variable name to the file name, it said the file existed.
And for the first one, even when I replaced the variable name with the file, it still wouldn't work until I took out the $+
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
Can you please show us exactly what you are using/typing? Unless we see the exactly syntax you are using for your example, we cannot possibly duplicate it, nor really explain it. The best we'll be able to do is take shots in the dark until one of us hits on a way to solve your particular problem - an iffy way to arrive at a satisfactory solution. - Try double-quoting your filename.
var %filename = " $+ filenameOrVariable $+ " var %filename = $+(",filenameOrVariable,") - $crc(%filename) will return 00000000 if the file doesn't exists, which is $false in an if condition.
- $exists(%filename) should works fine.
- $file(%filename) should work fine.
- $findfile($nofile(%directory),$nopath(%filename),1) should work fine.
- $lines(%filename) should work fine.
- $isfile(%filename) should work fine.
- $longfn(%filename) should work fine.
- $nopath(%filename) should work fine.
- $read(%filename) should work fine.
- $shortfn(%filename) should work fine.
Off the top of my head, I'd say it most likely has to do with how you're setting your variable but I wouldn't necessarily bet on it without a lot more information.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Dec 2002
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2002
Posts: 5 |
on 1:TEXT:~test:#: { if ( $exists( c:\mirc\files\ $+ $nick $+ .txt )) { echo -a yes it is there } | else { echo -a no it is not there } }
I was interested in seeing how $exists works, and wondered how you would do it with variables or the nickname of the person who tried it instead of typing the direct path. I made a text file named cyter.txt, and using the nickname cyter typed ~test. It kept telling me it didn't exist, but when I changed the path to c:\mirc\files\cyter.txt it told me it existed.
Don't know if mIRC versions has anything to do with it, but I'm using 5.82.
I probably still didn't answer your question, so if you have anything else to ask, I'll try to answer.
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
v 5.82? Have you considered joining us in the 21st century? :tongue: - 16 Aug 2002 - mIRC v6.03
- 06 Jun 2002 - mIRC v6.02
- 10 Feb 2002 - mIRC v6.01
- 03 Feb 2002 - mIRC v6.0
- 15 Jun 2001 - mIRC v5.91
- 26 Apr 2001 - mIRC v5.9
- 14 Dec 2000 - mIRC v5.82
2000 was the last year of the 20th century.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Dec 2002
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2002
Posts: 5 |
Wow, I think that might have been it. I decided to join you in the 21st century :tongue: and it turned out it now works. Thanks!
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
Use $isfile, not $exists reason is, if I create a folder named $nick $+ .txt, $exists will return true, but it's not a file, it is a folder. $isfile only returns true if it is a file, it will return false if it either doesn't exist or is a folder.
|
|
|
|
Joined: Dec 2002
Posts: 271
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 271 |
lol, welcome to the 21st yes, thats what i always use, $isfile, or $findfile, depending on what i am doing
|
|
|
|
|