mIRC Home    About    Download    Register    News    Help

Print Thread
#126307 27/07/05 06:24 PM
Joined: Nov 2004
Posts: 822
J
Jigsy Offline OP
Hoopy frood
OP Offline
Hoopy frood
J
Joined: Nov 2004
Posts: 822
As I tend to script big projects that require a lot of saving to ini files, and since looping through ... 100kb *.inis causes mIRC to freeze for a short period of time, so I thought that mIRC should have a $findline function.

So $findline(users.ini,user3) returns 7 etc.

#126308 27/07/05 06:44 PM
Joined: Nov 2004
Posts: 822
J
Jigsy Offline OP
Hoopy frood
OP Offline
Hoopy frood
J
Joined: Nov 2004
Posts: 822
Nevermind ... I coded my own

Code:
/findline {
  window -h @FindLine
  loadbuf 0 @FindLine $1
  var %line = $fline(@FindLine,* $+ $2- $+ *)
  window -c @FindLine
  return %line
}


Still .. it would be nice if mIRC had an 'official' one

Last edited by JigsZilla; 27/07/05 06:54 PM.
#126309 27/07/05 08:51 PM
Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641
what's wrong with $read() and $readn ?

** EDIT with more info **

//var %r = $read(users.ini, w, *user3*) | echo -a $readn

will echo 7

Last edited by argv0; 27/07/05 09:01 PM.
#126310 27/07/05 09:13 PM
Joined: Dec 2002
Posts: 3,534
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,534
Why don't you use $read()'s wildcard text and $readn to return the line number that was matched in the previous call to $read().

Code:
alias findline { 
  if ($isfile($1)) { 
    if ($read($1,w, $+(*,$2-,*))) { return $readn } 
  }
}


//say $read(readme.txt,Remember to visit) returns 26 if you have mIRC 6.16 readme file still.

This could be useful if implemented.

Edit: arg0 beat me to it.. laugh

-Andy

#126311 27/07/05 10:22 PM
Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
If you're having to search through a fair amount of data regularly you'd probably be better off using hash tables instead of an INI file anyway.

#126312 28/07/05 06:50 PM
Joined: Nov 2004
Posts: 822
J
Jigsy Offline OP
Hoopy frood
OP Offline
Hoopy frood
J
Joined: Nov 2004
Posts: 822
This is my slightly more modififed version

Code:
/findline {
  window -hk @FindLine
  loadbuf 0 @FindLine $1
  var %line = $fline(@FindLine,* $+ $2 $+ *,$iif($3 == $null,1,$3))
  window -c @FindLine
  return $iif(%line == $null,0,%line)
}


$findline(mirc.ini,sounds,1) returns 33
$findline(mirc.ini,sounds,2) returns 34
$findline(mirc.ini,sounds,0) returns 6 (how many 'sounds' there are in total)

... just add it to aliases and play around with it yourself. :P

#126313 28/07/05 10:30 PM
Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641
duhhh
were you not paying attention?
use $readn

you don't need that bloated beast of an alias

#126314 29/07/05 09:42 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Line numbers should not matter for ini files, ini files have different sections each with different entries, the location of a section/entry has no effect on it's meaning (well, it shouldn't)

Therefore I see no reason for implementing a strange alias that is against the very foundation of ini files.

And, what should your $findline(file.ini,entry1) return in this case:
[section1]
entry1=blub
entry2=blah

[section2]
entry1=maybethis
entry2=ploink

[section3]
entry1=yesitcangetworse


As for your problem:
-> use $read with one of the search switches and $readn
-> dump ini files, use a normal text file and use provious option
-> dump ini files, use a normal text file and use /fopen and the other commands/identifiers on that help page to write or read the entire ini file in one go
-> dump ini files and use a hash table, or several tables if needed <- my suggestion


Link Copied to Clipboard