I wrote this alias to simplify reading dynamic variables. It uses a format similar to token identifiers. I'll give a few examples.
In these examples, the following are true:
- Your nick is: Savage
- you are on SwiftIRC
- This was called via an on TEXT event
- The person who activated it is: Jaytea
- It was activated in: #Savage_CL
This is your variable file:
Note that the first doesn't have a seperator, the second uses ~ which is $chr(126), and the third uses a period, which is $chr(46).
Evaluations will be as follows:
$vget(test,$me,0) == hello
$vget(call,$nick,$chan,126) == world
$vget(this,$network,$chan,46) == mychan
You see that using 0 will cause the snippet to not use a seperator.
If you are writing a script that uses this identifier to call a variable multiple times without changing it, I suggest doing something like the following:
This is because the alias uses functions that aren't particularly fast (like the while loop) and it would be faster to use it only when needed.
If you find this useful or find any bugs, visit me in #Savage_CL on SwiftIRC or comment here.
Thanks!
PS I know this is a lot longer than it has to be and I could likely have done it in 3 lines, but I wanted to do it this way. It makes it easier to read in my opinion.
alias vget {
if (!$2) { echo -ea invalid parameters! | HALT }
var %toks = $0,%items = %toks - 1,%tokenizer = $ [ $+ [ %toks ] ],%t = 1,%name = $chr(37) $+ $ [ $+ [ %t ] ],%t = 2
while (%t <= %items) {
var %name = %name $+ $iif(%tokenizer,$chr(%tokenizer)) $+ [ $ [ $+ [ %t ] ] ]
inc %t
}
if ($(%name,2) != $null) {
return $v1
}
else {
echo 7 -ae %name is not set!
}
}