I'm posting this blindly without a care in the world if it already exists,
Creating bots that store dynamic data such as channel topics, parts of topics such as dividers and such are a pain in the backside when it comes to storing variables within mIRC.
Well for a project I'm working on I needed to do this, a lot.
So I've written a simple 'wrapper' for mIRC Variables.
This 'wrapper' allows you to use $+() when setting variables allowing you to set variables that are completely dynamic and headache free.
alias set-var {
; Sets a variable for a client
; Takes Var and Value
var %var $1
var %val $2-
set [ % $+ [ %var ] ] %val
}
alias get-var {
; Gets a variable for a client
; Takes Var
var %id $1
var %var $2
var %r % [ $+ [ %id ] ]
return %r
}
alias unset-var {
unset % [ $+ [ $1 ] ]
}
alias inc-var {
inc % [ $+ [ $1 ] ]
}
alias dec-var {
dec % [ $+ [ $1 ] ]
}
It's pretty simple to use and doesn't require anything special.
Here's an example of such a usage:
set-var $+($chan,.topic) Hello World
Then you can retrieve it via $get-var($+($chan,.topic))
If the variable doesn't exist it simply forwards mIRC's $null value.
If you want to try it out with the /echo command:
//set-var $+($chan,.topic) Hello World
//echo $get-var($+($chan,.topic))
Trying such a task with /set generally results in:
Trying to retrieve it is a pain in the ass and requires []'s
Enjoy this useful tool!
Let me know if its useful, apologies to anyone who's already made and released such a snippet on Hawkee!
Exactly, no need to use [ ], which are ugly and meant to alter the order of evaluation, $eval is slower, but more readable
@TMFKSOFT /set doesn't usually result in invalid parameter, only if you use it wrongly. Your wrappers are also very primitive, they don't allow the use of switches, and they only works for one 'layer' of dynamical name.