mIRC Home    About    Download    Register    News    Help

Print Thread
#126745 04/08/05 05:40 PM
Joined: Jul 2005
Posts: 29
G
goth80 Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 29
I'm attempting to list data stored in hash file though I want to list "names only", and not "status and name" I'd like to either retrieve even numbered lines (I know its an ugly way to get names only), or be shown a more elegant alternative to retrieve the name only lines.


Data stored in the following format:

loggedin.duderich
duderich
loggedin.liambonner
liambonner
loggedin.wythe
wythe

code used to extract data

Code:
  [color:red]

alias qlist {
  var %x = 1
  var %lines = $lines(qlist.hsh)
  while (%x <= $lines(qlist.hsh)) {
  echo -a $read(qlist.hsh,%x)
   inc %x
  }
}
 [/color]
 


Whats life without a little Karma?
maddkarma[dot]com
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Hey buddy.

Code:
alias qlist { 
  var %x = 1, %lines = $lines(qlist.hsh)  
  while (%x <= $lines(qlist.hsh)) {  
    if (loggedin* !iswm $read(qlist.hsh,%x)) echo -a $read(qlist.hsh,%x)
    inc %x  
  }
}


-Andy

Joined: Jul 2005
Posts: 29
G
goth80 Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 29
Hey SladeKraven smile)), you seem to always be on my "trouble tickets".. and that's a good thing. Thanks for the exceedingly fast response.

OUTSTANDING!

As expected, works flawlessly.


Whats life without a little Karma?
maddkarma[dot]com
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You're most welcome. smile

-Andy

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
I know you wanted to do it, but you forgot a part smile

while (%x <= %lines) {

and while we're at it, why not

if (loggedin* !iswm $read(qlist.hsh,%x)) echo -a $v2


If it's a very large hash file, you'll want to look at /fopen and such, but it's probably not worth the effort in this case...

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I forgot we even set that var, my bad. Had I remembered yes I'd of used it in the loop, and that $v2 well I always mean to do that and always forget, nice find though.. smile

-Andy

Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Another solution is using /filter:

Code:
/filter -fsx qlist.hsh . loggedin.*


Sends those lines to the status window

Joined: Jul 2005
Posts: 29
G
goth80 Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 29
Thanks for the input Sigh and Kelder

Hmm, and the script worked flawlessly, though now I'll work better :P And filters will be next on the study agenda considering they're less resource intensive (although duties for this snippet will be minor).

On a side note... Kelder, after reading numerous threads with you placing a "m/' in scripts, I became obsessed with finding the meaning. So I errrr, read through no less than 40 pages of regular expession tutorials including one by Sigh to find out that it meant... After discovering the meaning. Initially, I had the look of someone hit with a blunt object. Though after brief thought I was overjoyed to have leaned as much as I did searching for the meaning of it. smile)

Last edited by goth80; 05/08/05 03:24 AM.

Whats life without a little Karma?
maddkarma[dot]com
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
I'm surely glad you only had the look of someone hit by a blunt object :tongue:


Link Copied to Clipboard