mIRC Homepage

Search in INI.files

Posted By: Commander

Search in INI.files - 18/05/03 08:26 AM

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..
Posted By: coder

Re: Search in INI.files - 18/05/03 08:59 AM

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 ?




Posted By: Commander

Re: Search in INI.files - 18/05/03 09:38 AM

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...
Posted By: theRat

Re: Search in INI.files - 18/05/03 09:51 AM

How do you search the ini file?
Posted By: Commander

Re: Search in INI.files - 18/05/03 12:16 PM

Thats what i need to know it will be triggered by a command !search *
Posted By: Axehandler

Re: Search in INI.files - 18/05/03 12:54 PM

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
Posted By: qwerty

Re: Search in INI.files - 18/05/03 01:19 PM

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?
Posted By: Commander

Re: Search in INI.files - 18/05/03 01:35 PM

Qwerty it would scan item data...And Thanks Axe i will try that as well
Posted By: qwerty

Re: Search in INI.files - 18/05/03 02:51 PM

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.
Posted By: coder

Re: Search in INI.files - 18/05/03 03:54 PM

wow
u are excellent qwerty..
© 2020 mIRC Discussion Forums