Jump to content

.ini Question


Silo

Recommended Posts

Heh, Thanks for the kind words, Warrior :P I'm pretty excited about finally getting some .ini stuff to work. This is going to revolutionize the way I write scripts now :)

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

Hey good job! I ALWAYS use return. The only time I use halt is in an event to stop mirc from echoing the info to the screen.

 

Halt stops all executing scripts. Return stops the currently executing script.

 

The time I had issues with variables I figured out what the problem is and it's good for you to know actually.

 

When mIRC starts and loads, it loads ini files. These files, like vars.ini, are stored in RAM. You can change the actual file and you wont see a difference in mIRC until it re-initializes. Because of this you cannot manually edit .ini files unless you use the /flushini command. BY manually edit I mean opening the file in a text editor and editing it. Using /writeini is fine.

 

 

/flushini <filename>

 

Flushes the specified INI file to the hard disk. INI files are cached in memory, so you may want to do this to make sure that your INI is updated properly.

 

And one last thing. What revolutionized the way I write scripts was learning hash tables and tokens. LEarning hash tables taught me about tokens. These two tools and concepts will do wonders. Especially tokens. And they both are actually very easy. Hash tables use less code than ini files. Supposedly faster too. In fact I learned hash tables before ever even working with ini files. I use ini now for storing basic settings.

 

 

Anyways, well done! Keep it up!

 

Link to comment
Share on other sites

Wow, thanks, Travis. That is very informative, and I'm embarrassed to say - I've been manually deleting messy entries in my .ini file (the stuff that didn't work)! I guess I should flush the file and start again?

 

Another question: I've made an alias to shorten the path of the file ($_data) instead of (Engine/Text/Channel_Data.ini) and it works very well. I thought "why can't I take this a step further and make a similar alias return <file name> <section> <item> so I thought I could use

 

alias _rd {
  return $readini(testers.ini,$1,$2)
}

On *:Dialog:check.test:sclick:10:{
  writeini -n testers.ini Prots hop $did(1).state 
  writeini -n testers.ini Prots flood $did($dname,2).state
  writeini -n testers.ini Prots ctcp $did($dname,3).state
}
On *:Dialog:check.test:init:*:{
  if ($_rd == 1) did -c $dname  1
  if ($readini(testers.ini,prots,flood) == 1) did -c $dname  2
  if ($readini(testers.ini,prots,ctcp) == 1) did -c $dname  3
  if ($readini(testers.ini,prots,enable) == 1) did -c $dname  4
}

 

So this bit is failing BIG time

  if ($_rd == 1) did -c $dname  1

 

Is my idea of using $1 & $2 off or is something simpler, I'm missing?

 

Both you & Warrior have a great help me to, so I'd also like to publicly thank the both of you for your help & support :)

Link to comment
Share on other sites

HI Zan, yeah, it works no problemo the way you suggested. I was trying to not have to write the items etc after the alias thus why I thougt $1 & $2 would return that info :)

Link to comment
Share on other sites

You need to provide the alias with $1 and $2.

 

/testing 1.. 2.. 3.. 4..

alias testing {
  echo -a 1= $1 2= $2 3= $3 4= $4
  echo -a > $1-2
}

 

Result:

 

1= 1.. 2= 2.. 3= 3.. 4= 4..

> 1.. 2..

 

alias _rd {

return $readini(testers.ini,$1,$2)

}

 

You need to tell the _rd alias what $1 and $2 are.

 

If used as a command, the info is seperated by spaces.

So if you use: /testing One,Two Three,Four

 

$1 == One,Two and $2 == Three,Four

 

(incidentally the space that seperates them is considered a token. $chr(32) )

 

When using the alias as an identifer, i.e.: $_rd, the data is seperated by commas. The comma is considered the token $chr(44).

 

$testing(One..Two,Three..Four) $1 == One..Two and $2 == Three..Four

 

 

So you would provide $1 and $2 with your custom identifier as Zan showed you.

 

$_rd(prots,flood) == $readini(testers.ini,prots,flood)

 

 

Link to comment
Share on other sites

Ahhhhh right, I totally get you. Apologies to Zan, I missed his point entirely, and since I use parenthisis to wrap customer identifiers I should of seen what he was saying.

 

Thanks guys, that's been of great help to me.

 

PS - I'm like a kid with a new toy since grasping this. Stuff I've been putting off for weeks because I couldn't accomplish it with %vars was all done in less than twenty minutes last night using .ini. :embar:

Link to comment
Share on other sites

Hey Silo, well done. It really is a pleasure working with someone who actually wants to learn and not just be given some code to copy and paste. So ... what's next!? hehe

Link to comment
Share on other sites

Thanks Travis, it's only with the help of great people & tutors like yourself that inspire me & help me push my boundries :)

 

Next? Well probably quite basic for most really :P I'm trying to use MDX to make only my Nickname blod in my custom nicklist. So far they all keep coming out bold :(

Link to comment
Share on other sites

Excuse the double post, I wanted to add another question to the topic and (I confess) wanted to bump it :)

 

This is a follow on to Travis's indepth lesson he shared me with (If you (Travis, that is) had the interest perhaps you could write tutes, as you have a very easy way of explaining things).

 

Ok, after being pretty happy with my results of your teaching, I thought I'd tackle the original question I was posting about in the first place. I followed a different path to what you suggested, and time may prove this a foolish step as this progresses.

 

[Protection]
#err0rtest=Revenge=1,Profanity=1
#Scripters=Revenge=1,Hop_Flood=1,Profanity=1,Mode_Lock=1

 

As you can see, I added the channel first then add the prots to it via $addtok (I'm getting the feel for it, slowly). Note the = 1 This was the result of some messy coding which I used for experimentation purposes since I thought it would be easy to show which boxes were ticked on init if Iused the

= 1 method.. Observe:

     ; if ($active !ischan) return
     ; if ($me !isop $ifmatch) { $input(You need Op status or higher to make these changes,hdo,HALT) | return }
      if ($did(119).state == 1) writeini $_prots Protection $active $addtok($readini($_prots,Protection,$active),Revenge,44) $+ $chr(61) $+ $did(119).state
      if ($did(104).state == 1) writeini $_prots Protection $active $addtok($readini($_prots,Protection,$active),Hop_Flood,44) $+ $chr(61) $+ $did(104).state
      if ($did(99).state == 1) writeini $_prots Protection $active $addtok($readini($_prots,Protection,$active),Profanity,44) $+ $chr(61) $+ $did(99).state

 

This is the alias I use to call the checked boxes on init (I'm pretty embarrasses about this, but hey, I am learning & it is only experimental at this stage :P )

alias show.prots {
  if (!$dialog(cpanel)) { return }
  if ($active isin $readini($_prots,Protection,Revenge))  did -c cpanel 119 
  if ($active isin $readini($_prots,Protection,Hop_Flood) && ($readini($_prots,Protection,Hop_Flood == 1)) did -c cpanel 104
  if ( $active isin $readini($_prots,Protection,Profanity) && ( $readini($_prots,Protectio,Profanity) == 1) ) did -c cpanel 99
}

 

I've only made two checks so far. No need to write a bunch of them until they work :)

 

Any advice for me Mr. Travis or others? :)

 

Thanks you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...