mIRC Homepage
Posted By: PhyxiuS c0mm4nds - 03/05/06 07:39 PM
Hi, i've been trying/creating alot, but still didn't found any of them... Where i'm searching for is, when i type:

.list C:\Pictures\*.*

That it will show all the files in that map to echo in my mIRC
like:
[ C:\Pictures ` jippii.jpg ]
[ C:\Pictures ` jippii2.jpg ] , etc...
-
Also when i do this: .list C:\Stuff\*.txt
(that i will show all the .txt files in the map & this with everything)
-
Also: .remove C:\Pictures\jippii.jpg
&
.mkdir C:\testz (so the script will create a directory "Testz")

-

Thankx anyway grin
Posted By: SladeKraven Re: c0mm4nds - 03/05/06 07:58 PM
This probably isnt what you want but try:

Code:
On *:Input:*: {
  if (.list == $1) {
    var %x = 1, %sdir = $$sdir= " Select Dir "
    while (%x <= $findfile(%sdir,$iif($2,$2,*.*),0)) {
      echo -a $+([,$findfile(%sdir,$iif($2,$2,*.*),%x),])
      inc %x
    }
    halt
  }
}
Posted By: PhyxiuS Re: c0mm4nds - 03/05/06 08:10 PM
No, it just has 2 echo the files from the map to my mIRC Window... Without have 2 do anything else, not selecting the map first or somethin'...
Posted By: SladeKraven Re: c0mm4nds - 03/05/06 08:18 PM
Code:
On *:Input:*: {
  if (.list == $1) {
    tokenize 124 $1-
    var %sdir = $gettok($1,$+(2,-,$numtok($1,32)),32)
    if (%sdir) {
      var %x = 1
      while (%x <= $findfile(%sdir,$iif($2,$2,*.*),0)) {
        echo -a $+([,$findfile(%sdir,$iif($2,$2,*.*),%x),])
        inc %x
      }
      halt
    }
  }
}


.list <directory>|<extension>

Example:

.list C:\mIRC|*.ico

Lists all *.ico files.

If you don't specify an extension:

Example:
.list C:\mIRC

Lists all files in mIRC.

-Andy
Posted By: PhyxiuS Re: c0mm4nds - 03/05/06 08:55 PM
Works great ! u also know the .remove & .mkdir code? confused
Posted By: schaefer31 Re: c0mm4nds - 03/05/06 09:09 PM
Why re-invent the wheel?

/help /remove
/help /mkdir
Posted By: SladeKraven Re: c0mm4nds - 03/05/06 09:17 PM
Code:
On *:Input:*: {
  tokenize 124 $1-
  if (.list == $gettok($1,1,32)) {
    echo -a $1-
    var %sdir = $gettok($1,$+(2,-,$numtok($1,32)),32)
    if (%sdir) {
      var %x = 1
      while (%x &lt;= $findfile(%sdir,$iif($2,$2,*.*),0)) {
        echo -a $+([,$findfile(%sdir,$iif($2,$2,*.*),%x),])
        inc %x
      }
    }
  }
  elseif (.remove == $gettok($1,1,32)) {
    var %sdir = $gettok($1,$+(2,-,$numtok($1,32)),32)
    if (%sdir) {
      var %x = 1
      while (%x &lt;= $findfile(%sdir,$iif($2,$2,*.*),0)) {
        remove $+(",$findfile(%sdir,$iif($2,$2,*.*),%x),")
        inc %x
      }
    }
  }
  elseif (.mkdir == $gettok($1,1,32)) {
    $1-
  }
}


Untested.
Posted By: hixxy Re: c0mm4nds - 04/05/06 10:35 AM
Code:
on *:input:*:{
  if ($1 == .list) {
    noop $findfile($deltok($2-,-1,92),$gettok($2-,-1,92),0,echo -a $+([,$1-,]))
    haltdef
  }
  elseif ($istok(.mkdir .remove,$1,32)) {
    $1-
    haltdef
  }
}


This one will allow the format you asked for (.list c:\test\*.*) and should be a lot faster than SladeKraven's.

SladeKraven:

Calling $findfile in a loop is bad enough, but calling it twice in a loop is absolutely horrendous.

This is what your script does:

$findfile within while loop counts all files in the directory. This information isn't stored, it has to count all of the files each time. If you had 1000 files in a directory, all .avi, and he matched .avi, your script would have to count 1000000 files without even considering the second $findfile.

First file:
This will go through every file until it finds the first matching file.

Second file:
This will go through every file until it finds the second matching file.

Third file:
This will go through every file until it finds the second matching file.

My version will go through every file once and echo any matches. For huge directories it could be over 1000 times faster.
Posted By: PhyxiuS Re: c0mm4nds - 04/05/06 08:35 PM
Hmmm, i want 2 use it as command on my Channel Security Bot. So, don't think that "input" stuff is needed... HixxY, i also think u did some mistakes in the script, cuz when i type:

.list C:\Movies\*.*

-
Aint working... :s
Posted By: PhyxiuS Re: c0mm4nds - 04/05/06 08:41 PM
I already tried something by myself:

Code:
on *:TEXT:*:#:{  
  if ($2- == .list) {
    noop $findfile($deltok($2-,-1,92),$gettok($2-,-1,92),0,echo -a $+([,$2-,]))  
    haltdef 
  }  
  elseif ($istok(.mkdir .remove,$2-,32)) {   
    $2- 
    haltdef  
  }
}


Aint working
Posted By: hixxy Re: c0mm4nds - 05/05/06 12:01 AM
You modified the code, that's why..

Code:
on *:TEXT:*:#:{  
  if ($1 == .list) {
    noop $findfile($deltok($2-,-1,92),$gettok($2-,-1,92),0,echo -a $+([,$2-,]))  
    haltdef 
  }  
  elseif ($istok(.mkdir .remove,$1,32)) {   
    $2- 
    haltdef  
  }
}
Posted By: PhyxiuS Re: c0mm4nds - 05/05/06 07:04 PM
Hmmm,

"noop $findfile"

Where is noop standing for? crazy

Isn't it "LOOP" ... confused
Posted By: PhyxiuS Re: c0mm4nds - 05/05/06 07:12 PM
HixxY, that code aint working either... & the ".mkdir" (to create a directory, like:

.mkdir C:\Test123 (aint working) (= (21:07) -› C:\Test123 is an unrecognised command)

.remove C:\Test.txt (aint working) (= also an unrecognised command) & i know... The code isn't scripted in ur code HixxY, + the .list aint working either shocked
Posted By: hixxy Re: c0mm4nds - 05/05/06 07:12 PM
No. noop means "no operation" or "do nothing" - we need to call $findfile but we don't need to do anything with the data it returns, so we use /noop on it.
Posted By: hixxy Re: c0mm4nds - 05/05/06 07:15 PM
My bad, try this:

Code:
on *:TEXT:*:#:{  
  if ($1 == .list) noop $findfile($deltok($2-,-1,92),$gettok($2-,-1,92),0,echo -a $+([,$1-,]))  
  elseif ($istok(.mkdir .remove,$1,32)) $1- 
}


Make sure you remove any other versions of the script and DON'T modify it this time.
Posted By: PhyxiuS Re: c0mm4nds - 05/05/06 07:54 PM
That's working. I've got my Security Bot working now, a m8 told me it would be better if i would use sockets for it.
I've got a socket security bot running right now.
-
This is what I've got:
Code:
alias list1ng {
   if ($1 == .list) noop $findfile($deltok($2-,-1,92),$gettok($2-,-1,92),0,echo -a $+([,$1-,])) 
  elseif ($istok(.mkdir .remove,$1,32)) $1-
}

 if (*:.list* iswm %read) {
   do.wr1t3 privmsg %channel : $+ list1ng
 }



It aint right, but I tried...
-
It's like these way cuz it's connected via a socket...
I also tried Channel Show/Hide, but it doesn't hide the status bar, so i have 2 keep a second server running for my security bot, I prefer sockets...
-
When i type:
.list C:\blabla\*.* (like before) that it msg's the founded files to the %channel.
.mkdir C:\blabla (then msg's to channel: $dir succesfully created, if not created= error)
.remove C:\blaaat.txt (msg: $file succesfully removed)
-
Is this possible?
Posted By: FiberOPtics Re: c0mm4nds - 06/05/06 02:34 AM
I've pointed out Sladekraven's inefficient usage of $findfile plenty of times, but somehow it doesn't seem to get through to him.
Posted By: SladeKraven Re: c0mm4nds - 06/05/06 03:32 AM
Blah de blah blah. Aren't you supposed to be gone?
Posted By: DaveC Re: c0mm4nds - 06/05/06 07:50 AM
I would like to point out your inefficient usage of blah, i feel 2 blahs would have done nicely. :-)
Posted By: SladeKraven Re: c0mm4nds - 06/05/06 07:51 AM
Heh, I got lost in the moment. :tongue:
Posted By: hixxy Re: c0mm4nds - 06/05/06 08:01 AM
You would have to do something like this:

Code:
alias list1ng {
   if ($1 == .list) noop $findfile($deltok($2-,-1,92),$gettok($2-,-1,92),0,do.wr1t3 privmsg %channel $+(:[,$1-,])) 
  elseif ($istok(.mkdir .remove,$1,32)) $1-
}


Code:
tokenize 32 %read
if ($mid($4,2) == .list) list1ng $mid($4-,2)
elseif ($istok(.remove .mkdir,$mid($4,2),32)) $mid($4-,2)


The above code would have to go inside of your on sockread event.
Posted By: FiberOPtics Re: c0mm4nds - 06/05/06 10:43 AM
Whether I'm gone or not is irrelevant.

Now, if you simply didn't know about how to use $findfile properly, then someone would perhaps point this out more gently, but when you've been told this atleast 5 times by me, and no doubt probably by some others as well, then that just shows your unwillingness to listen and improve. This is not a personal attack, it's simply the truth. You know it, and I know it.

You are probably wondering why this matters? When you post code here, you should remember you are posting on public forums, where multiple people can see your code. Learning scripting involves a lot of seeing other people's code, and looking at how they get things done. I've used the Search feature extensively when learning scripting, seeing how other scripters did things. However, if you set a bad example, some will follow you in that bad example, from which no one benefits at all, on the contrary.

Think about it, when you learn scripting, programming, or anything for that matter, would you prefer to see badly written examples, or well written examples?
Posted By: PhyxiuS Re: c0mm4nds - 06/05/06 07:10 PM
Well, uuhm... Nice conversation smile

But can someone try to solve my problem? :tongue:
Posted By: hixxy Re: c0mm4nds - 06/05/06 07:13 PM
Try reading the replies!
Posted By: PhyxiuS Re: c0mm4nds - 06/05/06 07:18 PM
Already did, just didn't saw the "page: 2"
Posted By: PhyxiuS Re: c0mm4nds - 06/05/06 07:51 PM
HixxY, the code aint working, and i putted it all 100% right.
It's something like this:

Code:
  if (%list == bla || %mkdir == bla || %r3move == bla)  { do.writ3 privmsg %channel : $+ $read(%list) &amp; if ($readed == %list) { (show the requested list of files) &amp; if = mkdir (create dir) &amp; if remove (removedir)  }


So, actually, the %list becomes the script u created... But just in 1 simple word "%list" ... ;\

This code is totally wrong, but I just don't know how to do it...
Posted By: hixxy Re: c0mm4nds - 06/05/06 08:06 PM
Hmm I told you how it should be done. If you don't know how to edit a script I can't really help you.
Posted By: PhyxiuS Re: c0mm4nds - 06/05/06 10:39 PM
Anyone can help me?
Posted By: FiberOPtics Re: c0mm4nds - 07/05/06 01:50 AM
The only one that will help you is yourself, really. If you can't get something as easy to work, it's time to pick up scripting. We will assist you with any problems you occur, but you'll have to do the majority of the work yourself. Read some tutorials, check some other users' socket scripts, and you'll be ready to go.
Posted By: PhyxiuS Re: c0mm4nds - 07/05/06 07:44 AM
Yeah m8, my socket script is working fine... it's just that ".list" and ".mkdir" and ".remove" ... It's not easy to put that in my Socket Script, i did like HixxY said, but, i know it aint right.
-
I've already know the way of doing it right, but, HixxY...
Can you please put this ".list" & ".mkdir" & ".remove) in parts? That those r not together.
-
Like this:

if (*:.list iswm %read) {
do stuff
}
if (*:.mkdir iswm %read) {
do stuff
}
& also with .remove ...
-
That's my only problem, HixxY's code = 1, have to split them in 3...
-
... ? confused
Posted By: hixxy Re: c0mm4nds - 07/05/06 08:26 AM
That's NOT the correct way to do it.

If I type "Hi :.mkdir c:\x" that would create a directory using your method. I already gave you the correct code several posts back.
Posted By: PhyxiuS Re: c0mm4nds - 07/05/06 01:53 PM
That code aint the right code, and I don't know how to fix that, cuz my Socket Script is like I said above.
Posted By: hixxy Re: c0mm4nds - 07/05/06 01:57 PM
Have you tried what I gave you before?
Posted By: PhyxiuS Re: c0mm4nds - 09/05/06 06:06 PM
Yes, I did.
© mIRC Discussion Forums