mIRC Home    About    Download    Register    News    Help

Print Thread
#3631 27/12/02 05:35 AM
Joined: Dec 2002
Posts: 5
C
cyter Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
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.

#3632 27/12/02 05:39 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Code:

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. cool



DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#3633 27/12/02 06:28 AM
Joined: Dec 2002
Posts: 271
N
Fjord artisan
Offline
Fjord artisan
N
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

#3634 27/12/02 07:55 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
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. smile
Code:

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? smirk


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#3635 27/12/02 02:45 PM
Joined: Dec 2002
Posts: 5
C
cyter Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
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 $+

#3636 27/12/02 09:40 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
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
#3637 28/12/02 04:11 AM
Joined: Dec 2002
Posts: 5
C
cyter Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
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.

#3638 28/12/02 06:20 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
v5.82? shocked Have you considered joining us in the 21st century? :tongue:
  1. 16 Aug 2002 - mIRC v6.03
  2. 06 Jun 2002 - mIRC v6.02
  3. 10 Feb 2002 - mIRC v6.01
  4. 03 Feb 2002 - mIRC v6.0
  5. 15 Jun 2001 - mIRC v5.91
  6. 26 Apr 2001 - mIRC v5.9
  7. 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
#3639 28/12/02 03:22 PM
Joined: Dec 2002
Posts: 5
C
cyter Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
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!

#3640 28/12/02 08:40 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
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.

#3641 28/12/02 10:04 PM
Joined: Dec 2002
Posts: 271
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
lol, welcome to the 21st wink

yes, thats what i always use, $isfile, or $findfile, depending on what i am doing smile


Link Copied to Clipboard