mIRC Home    About    Download    Register    News    Help

Print Thread
Search in INI.files #24827 18/05/03 08:26 AM
Joined: Feb 2003
Posts: 13
C
Commander Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Feb 2003
Posts: 13
I Need some help please... Is It Possible to read a ini file for certain text and then display to channel what topic of the ini file it is in..

Re: Search in INI.files #24828 18/05/03 08:59 AM
Joined: Dec 2002
Posts: 60
C
coder Offline
Babel fish
Offline
Babel fish
C
Joined: Dec 2002
Posts: 60
use $readini(file.ini,section,item)

try //echo -a $readini(mirc.ini, mIRC, nick)

if u still dont understand what is section & item,open your mirc.ini
and u will see what is the section and item

example :

[files] <= is section
servers=servers.ini <= item
finger=finger.txt
urls=urls.ini
addrbk=addrbk.ini

if u type //echo -a $readini(mirc.ini,files,servers) it will return servers.ini

got it ?





Re: Search in INI.files #24829 18/05/03 09:38 AM
Joined: Feb 2003
Posts: 13
C
Commander Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Feb 2003
Posts: 13
Thanks for that but what i want is if someone does a search for a certain word it will scan the ini.file (Items) looking for that word and then display what Section it is in...

Re: Search in INI.files #24830 18/05/03 09:51 AM
Joined: Dec 2002
Posts: 774
T
theRat Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
How do you search the ini file?


Code:
//if ( khaled isgod ) echo yes | else echo no
Re: Search in INI.files #24831 18/05/03 12:16 PM
Joined: Feb 2003
Posts: 13
C
Commander Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Feb 2003
Posts: 13
Thats what i need to know it will be triggered by a command !search *

Re: Search in INI.files #24832 18/05/03 12:54 PM
Joined: Mar 2003
Posts: 10
A
Axehandler Offline
Pikka bird
Offline
Pikka bird
A
Joined: Mar 2003
Posts: 10
Sorry - this is not PROPER - but should give u the basics, should work... I think wink
NOT TESTED :P

Remote
---
#search on
on 1:!seach*:*:/Search $2 $username
#search end
---



Aliases
---
/search {
set %section 1
set %section $readini(FILE.INI, 1stArea, $1)
if (%section != 1) then {
set %section 1st area
/msg $3 found in %section
goto end
}
set %section $readini(FILE.INI, 2ndArea, $1)
if (%section != 1) then {
set %section 2ndarea
/msg $3 found in %section
goto end
}
:end
}

I know some of you code guru's can shorten this up ALOT. heck even change it around wink but basicly it checks each section for the word. if it exists, then it marks the section. and tells the user where it's located.

Very bad code I know :P been awhile thou.

Axe

Re: Search in INI.files #24833 18/05/03 01:19 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Do you want to scan item names or item data? For example in this .ini:

[blah]
one=foo
two=bar

is the script meant to scan "one", "two" etc or "foo", "bar" etc?


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Search in INI.files #24834 18/05/03 01:35 PM
Joined: Feb 2003
Posts: 13
C
Commander Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Feb 2003
Posts: 13
Qwerty it would scan item data...And Thanks Axe i will try that as well

Re: Search in INI.files #24835 18/05/03 02:51 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Code:
alias tfi {
  if !$read($1,nw,*?= $+ $2) { return }
  if $read($1,nw,[*?],$readn) { return $ini($1,$calc($ini($1,$mid($ifmatch,2,-1)) - 1)) }
  return $ini($1,$ini($1,0))
}


Usage: $tfi(<filename>,<search string>)
returns the section name, fex, in the example ini in my previous post, $tfi(filename.ini,bar) returns "blah"

Look up both $ini() and $read() in the help file and read carefully. What I'm doing here is use $read() to find the line number that contains the matching item. Then I use $read() again to search for the 1st section right after the line of matching item. If it's found, I use $ini() to get the previous section, which is the one that the matching item belongs to. If it's not found, it means that the matching item belonged to the last section of the file, so I use $ini($1,$ini($1,0)) to get that.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Search in INI.files #24836 18/05/03 03:54 PM
Joined: Dec 2002
Posts: 60
C
coder Offline
Babel fish
Offline
Babel fish
C
Joined: Dec 2002
Posts: 60
wow
u are excellent qwerty..