mIRC Home    About    Download    Register    News    Help

Print Thread
#137711 18/12/05 01:19 AM
Joined: Aug 2005
Posts: 25
E
enotsoc Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Aug 2005
Posts: 25
i have 3 ini file si store data in, how can i have the !check read from each , when someone types !check they will be msg'd the 5 most recent results, so if the first ini doent have 5 results id need it to move on to the next and so on if necesary
on *:TEXT:!check *:#channel:{
var %i = 0
var %script = C:\mirc\test1.ini , %k = 1
inc %i 1
msg $chan ( i used tokens here to get the data )
if (%i == 5) { halt }
%k = $calc($readn + 1)
}
if (%i = 0) {
msg $chan Cant Find $1-
}
}

as i said , it all works the way it is, but i need help with how to make it check a 2nd or more .ini files incase the first doesnt have any thing that matches. ive been tring but havent had any luck so now its time to ask for help.
All help is appreciated. thanx

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
What is the script searching for in the ini files? How are the files organized.. what sections/items/data? How does the data need to be sorted to get the top 5?

You will have to give more detailed info in order to get a good answer.

-genius_at_work

Joined: Aug 2005
Posts: 25
E
enotsoc Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Aug 2005
Posts: 25
well each .ini looks like this
1134869281 line1
1134869282 line2
1134869283 line3
......etc
basically the time, then the actual info , which i have no problem the way it is now, just not sure how to check other .ini's
is that enough info?
each ini should be identical to the other in most cases, but just incase, that is why i need to be able to check a 2nd or more .ini's , each comes from a diff source and one may update before the other.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I'd like to help you, really, but with the information you've given that won't be easy, and I don't like wasting time trying to figure out what exactly will be the best solution for you, when the given information is vague.

Quote:
i have 3 ini file si store data in


Why do you have 3 ini files, is there any particular reason that you don't put all your data in one ini file? While I'm at it, why an .ini file to begin with? Are you going to have to do a lot of checking these files, because that means continuous disk access, so a solution where your data is held in memory would be much prefered.

Quote:
when someone types !check they will be msg'd the 5 most recent results


What's the definition of recent here? How would I, he who does not know what you are trying to do, know what recent is and what is not. I would imagine that "recent" data is the last added data? Though isn't the last added data always in the 3rd .ini file?

What are results? Results of doing what...? you obviously want to check "something" in the ini file, but failed to explain what exactly should happen. Are you trying to match a topic, an item, an item's value? How is the matching to be done, is it with wildcards? What is a regular example of the parameters when typing !check <parameters>? How's your data structured, how are the .ini files set up?

A prerequisite for receiving help is doing the effort of clearly explaining any information that might be important to know.

All I can give you is an equally vague little template:

var %results = 0, %ini = <first ini>
while (%results < 5) {
; "match" $1- in whatever way you want in %ini, incrementing %results for each "match"
; if at end of ini, set %ini to second file,
; when at end of third ini, break out of the while loop even if %results< 5
}

That's just about all I can give you given the vagueness of your query...


Gone.
Joined: Aug 2005
Posts: 25
E
enotsoc Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Aug 2005
Posts: 25
i dont see what i have contained in the files matters, i explained in my reply , how its setup, all i need is help to have it check a 2nd 3rd or 4th ini if the first ini cant give me X amount of results

lets says its a quote database for irc, itll be on 3 channels , each channel will have its own ini., the only common factor is the !check trigger, so if i added quotes for a nick in channel1 only 1x , but i added or someone else added it 2x in channel2 and 2x in channel3 , since the first .ini doenst have 5 results, it will move on to the next .ini, so that when !check <nick> is triggered it will display the 5 max results.
the reaason for serperate ini is for any reason i decide to not want it in that channel anymore , i can easily just delete the ini. and not have any problems
i know there are other quote scripts, but that isnt what i want, id rather not use those.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
It sounds more like you will have to access all the ini files, and put the results into another file or @window with a "sort" parameter or command. as you have said that each quote is preceeded with $ctime, selecting the Last 5 quotes should then be the 5 most recent.

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
This is how you could read several ini files:

Code:
on *:TEXT:!check *:#channel:{

  var %inis = [color:green]"c:\test1.ini","c:\test2.ini","c:\test3.ini"[/color]
  var %F, %L = 0, %R = 0, %N = $+(1-,$numtok(%inis,44))

  while (%L &lt; %N) {
    inc %L 1
    %F = $gettok(%inis,%L,44)
    if (!$exists(%F)) { echo 4 -s Skipping %F | continue }

    [color:blue];;; Your comparison code goes here ;;;
    ;;; Use %F as the filename for $readini/$ini ;;;
    ;;; Increment the %R variable for each match ;;;[/color]
    
    if (%R &gt;= 5) break
  }

  if (%R &lt; 5) msg $chan Only found %R results

}


Green: Where you put a list of the ini paths/filenames. The list items should be enclosed in quotes ("") and separated by commas.

Blue: Since you claim to already have your code reading 1 ini file properly, you can insert your existing code in place of the blue area. The path/filename of the current ini file is stored in %F, so use it in commands like $readini(%F,section,item). The loop ends if all the ini files have been read, or %R <= 5. If %R < 5 after the loop ends, a message is sent out to the channel.

That is the best I can do with the information you have provided.

-genius_at_work

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
well each .ini looks like this
1134869281 line1
1134869282 line2
1134869283 line3
......etc
basically the time, then the actual info , which i have no problem the way it is now, just not sure how to check other .ini's
is that enough info?
each ini should be identical to the other in most cases, but just incase, that is why i need to be able to check a 2nd or more .ini's , each comes from a diff source and one may update before the other.


If your ini files are populated the way you say, then they are not true .ini files, but mere text files with the ini extension. Ini files have a specific structure, whereas text files (your case) have none. The structure is:

[topic]
item=value

Type //run $mircini, and see for yourself what a real .ini file looks like.

My suspiciouns were confirmed, you don't need to use multiple ini files at all, you can simply have them all in one ini file, with each channel being a topic:

[#help]
1134869283 line3
...

[#jokes]
1134869282 line2
...

Anyway, needless to say, if you want to make some sort of quoting bot, then using an .ini file (a true ini file) or text file etc. is not really a good idea, since its data isn't held in memory, which means for each lookup your mIRC has to do disk access.

Btw, when I started my first post in this thread, no one had replied yet, but by the time I was finished, you had already given a little (though not enough) information, which probably made my post look weird.


Gone.

Link Copied to Clipboard