mIRC Home    About    Download    Register    News    Help

Topic Options
#24827 - 18/05/03 09:26 AM Search in INI.files
Commander Offline
Pikka bird

Registered: 21/02/03
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..

Top
#24828 - 18/05/03 09:59 AM Re: Search in INI.files
coder Offline
Babel fish

Registered: 10/12/02
Posts: 60
Loc: Jupiter
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 ?





Top
#24829 - 18/05/03 10:38 AM Re: Search in INI.files
Commander Offline
Pikka bird

Registered: 21/02/03
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...

Top
#24830 - 18/05/03 10:51 AM Re: Search in INI.files
theRat Offline
Hoopy frood

Registered: 11/12/02
Posts: 774
How do you search the ini file?
_________________________
Code:
//if ( khaled isgod ) echo yes | else echo no

Top
#24831 - 18/05/03 01:16 PM Re: Search in INI.files
Commander Offline
Pikka bird

Registered: 21/02/03
Posts: 13
Thats what i need to know it will be triggered by a command !search *

Top
#24832 - 18/05/03 01:54 PM Re: Search in INI.files
Axehandler Offline
Pikka bird

Registered: 28/03/03
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

Top
#24833 - 18/05/03 02:19 PM Re: Search in INI.files
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
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

Top
#24834 - 18/05/03 02:35 PM Re: Search in INI.files
Commander Offline
Pikka bird

Registered: 21/02/03
Posts: 13
Qwerty it would scan item data...And Thanks Axe i will try that as well

Top
#24835 - 18/05/03 03:51 PM Re: Search in INI.files
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
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

Top
#24836 - 18/05/03 04:54 PM Re: Search in INI.files
coder Offline
Babel fish

Registered: 10/12/02
Posts: 60
Loc: Jupiter
wow
u are excellent qwerty..

Top