mIRC Home    About    Download    Register    News    Help

Print Thread
writeini and change multiple <value> #207640 25/12/08 04:39 PM
Joined: Dec 2008
Posts: 16
M
MrUser Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2008
Posts: 16
Hello,
i have an ini file
Code:
settings.ini
[options]
user1=bla|bla|bla|on
blah=bla|blabla|bla|off
...

possible change only the last section of the <value> ?? only the (on or off) cool
Code:
$gettok($readini($mircdirsettings.ini, options, user1),4,124)

with writeini i can change only the complete <value> frown
someone basic idea smile


bye
Re: writeini and change multiple <value> [Re: MrUser] #207644 25/12/08 05:03 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
var %a = $readini($mircdirsettings.ini,n,options,user1)
var %b = $gettok(%a,-1,124)
%a = $gettok(%a,1--1,124)
%a = $+(%a,$chr(124),$iif(%b = on,off,on)
.writeini -n $mircdirsettings.ini options user1 %a

Re: writeini and change multiple <value> [Re: RusselB] #207645 25/12/08 05:29 PM
Joined: Dec 2008
Posts: 16
M
MrUser Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2008
Posts: 16
merry xmas
thank you so much


bye
Re: writeini and change multiple <value> [Re: MrUser] #207655 25/12/08 09:53 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Looks like a good use for $reptok.


var %r = $readini(settings.ini,options,user1)
writeini settings.ini $reptok(%r,$gettok(%r,4,124),Off,1,124)


You would most likely use $1 instead of Off.

Here is an example.

Code:
/test On

menu channel {
Turn $iif($gettok($readini(settings.ini,options,user1),4,124) == On,Off,On) :test $iif($v1 == On,Off,On)
}

alias test {
var %r = $readini(settings.ini,options,user1)
writeini settings.ini $reptok(%r,$gettok(%r,4,124),$1,1,124)
}


Re: writeini and change multiple <value> [Re: DJ_Sol] #207659 26/12/08 09:24 PM
Joined: Dec 2008
Posts: 16
M
MrUser Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2008
Posts: 16
Hello,
Originally Posted By: DJ_Sol
Looks like a good use for $reptok.
Here is an example.

Code:
/test On

menu channel {
Turn $iif($gettok($readini(settings.ini,options,user1),4,124) == On,Off,On) :test $iif($v1 == On,Off,On)
}

alias test {
var %r = $readini(settings.ini,options,user1)
writeini settings.ini $reptok(%r,$gettok(%r,4,124),$1,1,124)
}


very nice smile working only in one site wink but good tip


bye
Re: writeini and change multiple <value> [Re: MrUser] #207660 27/12/08 01:07 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I'm glad you got use out of it. What do you mean one site? This has to do with an ini file.

Re: writeini and change multiple <value> [Re: DJ_Sol] #207675 27/12/08 08:53 PM
Joined: Dec 2008
Posts: 16
M
MrUser Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2008
Posts: 16
Hello,
i meant that it works only in one direction. To go back into starting position it has to be manual /test... .


bye
Re: writeini and change multiple <value> [Re: MrUser] #207682 27/12/08 11:11 PM
Joined: Dec 2008
Posts: 16
M
MrUser Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2008
Posts: 16
Hello,
i made an alternative with $reptok and i have put it in a $submenu

settings.ini:
Code:
[options]
blabla=bla1|bla2|bla3|on|bla4
user1=Test1|Test2|Test3|on|Test4

and here my $submenu
Code:
menu * {
  List
  .$submenu($sub_menu($1))
}
alias sub_menu {
  var %ini = $mircdirsettings.ini
  if ($ini(%ini,options,$1)) {
    var %item = $ifmatch
    var %tok = $readini(%ini,options,%item)
    var %state = $gettok($readini(%ini,options,%item),4,124)
    var %safe = $reptok(%tok,%state,$iif(%state = on,off,on),1,124)
    return $iif(%state == on,$style(1) %item %state,%item %state) : writeini -n %ini options %item %safe 
  }
}


bye