mIRC Homepage
Posted By: goth80 Selective reads from file - 04/08/05 05:40 PM
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]
 
Posted By: SladeKraven Re: Selective reads from file - 04/08/05 05:45 PM
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
Posted By: goth80 Re: Selective reads from file - 04/08/05 05:58 PM
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.
Posted By: SladeKraven Re: Selective reads from file - 04/08/05 06:10 PM
You're most welcome. smile

-Andy
Posted By: Kelder Re: Selective reads from file - 04/08/05 08:11 PM
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...
Posted By: SladeKraven Re: Selective reads from file - 04/08/05 08:16 PM
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
Posted By: Sigh Re: Selective reads from file - 04/08/05 09:36 PM
Another solution is using /filter:

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


Sends those lines to the status window
Posted By: goth80 Re: Selective reads from file - 05/08/05 03:21 AM
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)
Posted By: Kelder Re: Selective reads from file - 05/08/05 08:27 AM
I'm surely glad you only had the look of someone hit by a blunt object :tongue:
© mIRC Discussion Forums