mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
how would i accomplish listing all image files in a directory? i gather i would use $findfile and/or something like: if ($regex($lower(...),(jpg|jpeg|jpe|png|gif|bmp)) > 0) {


but i am not sure how to actually put the script together.

Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
Something like :
Code:
noop $findfile(path\,*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp,0,echo -a $1-)
?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
yes, perfect. is there a way i can change this to do, say 5 images, add a <br> then do the next 5? i must have all images in %nig before it is returned at the end of this alias.

Code:
alias -l new_img_gallery {
  var %nig = $chr(32)
  noop $findfile(scripts\pws\htdocs\gallery\,*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp,0,var %nig = %nig <a href=" $+ gallery/ $+ $nopath($1-) $+ "><img src=" $+ gallery/ $+ $nopath($1-) $+ " width="50" height="50"></a>)
  return %nig
}

Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
Add an $iif and check for $findfilen, like :
Quote:
var %nig = %nig <a href=" $+ gallery/ $+ $nopath($1-) $+ "><img src=" $+ gallery/ $+ $nopath($1-) $+ " width="50" height="50"></a> $+ $iif($findfilen // 5,<br>)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
its returning a <br> after the first, and after the 4th in the new line after the 8th in the third line. but if there are 36 images i get
* /set: line too long

but i dont know where in my script that is coming from. i will work on that though.


edit:
this works:

$iif($right($findfilen,1) == 5 || $right($findfilen,1) == 0,<br>)


is there a way to make mirc tell me where that /set error occurred

Last edited by MTec007; 30/01/09 11:24 PM.
Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
I meant $iif(5 // $findfilen,<br>) (your code work too, but this is better)
Error can be handle by using the :error goto in a script but here, it's clearly the /var in the $findfile which give this error


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
i actually think the error is from the alias /brepbytes which is not my alias, so im not sure how to fix it.

Code:
/brepbytes &temp $+(%,_IMG_GALLERY_,%) $new_img_gallery

alias -l new_img_gallery {
  var %nig = $chr(32)
  noop $findfile(scripts\pws\htdocs\gallery\,*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp,0,var %nig = %nig <a href=" $+ gallery/ $+ $nopath($1-) $+ "><img src="a $+ gallery/ $+ $nopath($1-) $+ " width="50" height="50"></a> $+ $iif(5 // $findfilen,<br>))
  return %nig
}

alias -l brepbytes {
  var %p,%s,%r = 1,%l = 1
  bunset &replace
  while (%l <= $bvar($1,0)) {
    while ($bfind($1,%l,$2).text) {
      %p = $ifmatch
      while (%l < %p) {
        bset &replace %r $bvar($1,%l,1)
        inc %r
        inc %l
      }

      bset -t &replace %r $3-
      inc %l $len($2)
      inc %r $len($3-)
    }
    bset &replace %r $bvar($1,%l,1)
    inc %r
    inc %l
  }
  %l = 1
  while ($bvar(&replace,%l,1) != $null) {
    bset $1 %l $ifmatch
    inc %l
  }
}

Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
In this alias, the only thing you do with variable is /inc.The /set line too long error mean that you've reached the line lenght limit of mIRC which is now ~ 4100 character (~ 940 before mIRC 6.32).
Since you're using a long string for each file found in the $findfile, and you've said in was reporting this only with many file, it's certainly this /var that cause the error.

Last edited by Wims; 31/01/09 10:34 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard