Simple Variables

By TMFKSOFT on Aug 15, 2015

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:

  • /set: invalid parameters

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!


Sign in to comment.
[Plornt]   -  Aug 20, 2015

Pretty neat, but not sure if you knew or not you can use the following to do this:

    set $+(%,$chan,.myvar) Something
    echo -a $($+(%,$chan,.myvar),2) 

Which is a tad more readable than the [] style of evaluating.

Wims  -  Aug 24, 2015

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.

TMFKSOFT  -  Aug 24, 2015

Probably, I've not touched mIRC code in years. lol.
and how do you mean one layer?

Wims  -  Aug 24, 2015

Nevermind about the layer stuff ^^'

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.