mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
hey,
i am making a script and so far it hs all been working out
for me, but i need to use some kind of way of checking the file
exists in the correct dir'.
i tried using $isfile to get it to work
but it wont
can you help me or tell me another way to go about this
thanks,

i set a variable for the file / name / dir
so then
i would use:
var %chkfile = %dir $+ \ $+ %file
i tried to make it an alias so i could call on it at otherpoints
this is what i had:

on *:TEXT:!read*:*:{
if (!$2) { msg $nick Syntax: !read File
msg $nick Example: !read readme.txt }
elseif ($2) && ($chkfile($nick $2) != $true {
msg $nick Sorry Invalid File }
else { play $nick %file1 }
}
alias chkfile {
var %name = $1
var %file = $2
set %file1 %dir $+ %file
;i already had a variable %dir value of c:\mirc\text-files

if ($isfile(%file) = $true) {
return $true
msg %name Playing You Requested TextFile
}
else { return $false }
}


please help me out
thanks alot

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Try using $exists for that.

$exists(file/dir)
Returns $true if a file or dir exists and $false if it doesn't.
$exists(c:\mirc\mirc.exe) returns $true or $false.


Hope this helps smile
Zyzzyx


"All we are saying is give peace a chance" -- John Lennon
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
yes i think its the same as $isfile
$isfile both work when i type the whole
path and file togather
like //echo -a $isfile(c:\mirc\mirc.exe)
but in my script where it uses a var
+ \ + var
it wont seem to work
any ides
and thanks alot
for the reply
wink

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Maybe there is a small detail...

%dir = c:\mirc\text-files\

Try that. I dont know if it was just a typo in your post, but if the dir is set to c:\mirc\text-files and you add a filename (eg: quit.txt) it would turn out to be: c:\mirc\text-files[color:blue]quit.txt[/color] instead of c:\mirc\text-files[color:red]\[color:blue]quit.txt[/color][/color]

Hope this helps smile


"All we are saying is give peace a chance" -- John Lennon
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
oops soory it was a typo
:P
"var %dir = $2- $+ \"
but the weird thing is
no matter how i try scriptwise it wont work
but if i type it in plain commands
without an $1 $nick and so on
it works perfectly

i wonder if its because i use my alias
like: $aliasname($nick $2-)
does it still work with spaces
maybe thats why a var cannot be set because it doesnt count $2
?
im stuck here

thanks alot for the help
smile



Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Hmm.. don't know. The use of spaces in $aliases() is possible, like when you have $len().. but I don't know about identifiers in an alias. Try adding them with a separator of some kind.

Eg: $chkfile( $+($nick,=,$2) )

And then use $gettok to set %name and %file. It is just a wild guess here.


"All we are saying is give peace a chance" -- John Lennon
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
already tried that aswell
lol
theres something up with this it seems to just halt the script
i mean i have more commands and else {
stuff after and it doesnt even get done
i added lots of echos to see how far it made it go through the script and it hasnt worked?
anyways i can get round this
??
im really stuck here
ive been trying to do it myself for about 2 days
on just this one part
but i cant lol
thanks for helping
i made the code smaller to test this certain part
but no luck frown
:-
on *:TEXT:!read:*:{
var %dir = c:\mirc\text-files
var %file = $2-
if ($exists(%dir $+ \ $+ %file) == $false) { msg $nick Sorry No! }
else {
echo -a 4th line of script
}

}

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
There are a few problems here.

1.

If you use $chkfile($nick $2) then $1 is $nick $2, parameters in an identifier are seperated with a comma, therefore, your code should be this: $chkfile($nick,$2).

2.

return $true
msg %name Playing You Requested TextFile


When return is used, mIRC exits the alias, so therefore anything after return will not be executed, to fix this just put return after the msg line.

3.

You're missing a ) on this line:

elseif ($2) && ($chkfile($nick $2) != $true {
msg $nick Sorry Invalid File }

It should be:

elseif ($2) && ($chkfile($nick,$2) != $true) {
msg $nick Sorry Invalid File }

4.

Not that it makes a difference most of the time, but using = instead of == can give errors sometimes, change:

if ($isfile(%file) = $true) {

To:

if ($isfile(%file) == $true) {


Edit: this post was in reply to your first unedited post.

Edit 2:

Try this:

Code:
on *:TEXT:!read *:*:{
     if (!$2) { 
          msg $nick Syntax: !read File
          msg $nick Example: !read readme.txt 
     }
     elseif (!$isfile(%dir $+ $2)) { msg $nick Sorry Invalid File }
     else { 
          msg $nick Playing you $2
          play $nick " $+ %dir $+ $2" 
     }
}

Last edited by tidy_trax; 10/09/04 08:27 PM.

New username: hixxy
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
lol
stupid little mistakes
frown
sorry about that
got it working now
thanks alot for the help Zyzzyx and tidy_trax
:P


Link Copied to Clipboard