mIRC Homepage

$1 returns nothing sometimes

Posted By: AshBurry_Kim

$1 returns nothing sometimes - 11/10/20 04:28 PM

I have come across an issue where $1 sometimes returns nothing.

The issue was when I called an alias with some data the data started with an unstripped $chr(32) in the front and $1 returned blank. $1- returned the $1 as normal but with an extra space in the beginning that would not come off until I broke it down in to a chip32 alias shown below. Also $2 would just return the second parameter if there is one in any case it ignores $1 all together.

alias chip32 {
if (!$isid) { return }
; # only used to remove the leading space from corrupt $1
; #
var %text = $1-
tokenize 32 %text
if ($0 == 0) {
if ($prop == noerror) { return }
echo -es syntax : $!chip32(<some text>) | halt
bunset &bvar &bvarset
bset -t &bvar -1 $1-

var %char = $bvar(&bvar, 1)
var %i = 1
while (%char == 32) {
inc %i
var %char = $bvar(&bvar, %i)
if (%i > $bvar(&bvar,0)) { return }
bset &bvarset -1 $bvar(&bvar, %i $+ - $+ $bvar(&bvar,0))
bunset &bvar
var %i = $bvar(&bvarset, 0)
var %char = $bvar(&bvarset, %i)
while (%char == 32) {
dec %i
%char = $bvar(&bvarset, %i)
return $bvar(&bvarset, 1- $+ %i).text

Use $chip32($1-) you must use it on $1- or it will not do anything useful. Since I found this issue and forgot how to reproduce it so I use chip32 on all my input especially from a socket. Also I started to strip all kinds of characters from my text: I have $stripchar() & $stripchar_clean() & $stripchar_basic() to remove confusing characters from filenames for example that I do not want to start with a $ % nor an & nor @ nor # nor an = because these are used for mirc special purposes it would confuse me if someone running code on my computer made a file that started with one of these characters I would not be too happy because it is confusing to me. I also strip <> ' , " ; ` * ? ()[] {} / \ + with these 3 identifiers. Stripping Input to an identifier or alias regardless of where the data comes from. I also use alias -l _cmd as much as possible to prevent people from running commands on my computer that may corrupt my work and settings. As long as there is still a 500kb script file size I am okay to use mirc's variables for most (or all) of my settings with $global.getval(my_variable_name) and /temp.set.var $gvar(my_variable_name) for example. It would be nice if $global.getval() auto detected if it was a global variable, session variable, setup variable, or neither-nor. and stripped leading space from variable name.

Anyone have an idea why this would happen?
© 2020 mIRC Discussion Forums