mIRC Home    About    Download    Register    News    Help

Print Thread
#126745 04/08/05 05:40 PM
G
goth80
goth80
G
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]
 

Joined: Dec 2002
Posts: 3,534
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,534
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

G
goth80
goth80
G
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.

Joined: Dec 2002
Posts: 3,534
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,534
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,534
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,534
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

S
Sigh
Sigh
S
Another solution is using /filter:

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


Sends those lines to the status window

G
goth80
goth80
G
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.
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