mIRC Home    About    Download    Register    News    Help

Print Thread
if else #261911 11/12/17 12:37 AM
Joined: Feb 2017
Posts: 19
D
Doctor_Souza Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Feb 2017
Posts: 19
;;;inside theme i use $chkc2, but sometimes it works other times do not, anybody know what the problem is?
;;; the variable %nop2 is set with "$nick($chan,$nick).pnick"

alias checknick2 {
if ($left(%nop2,1) == $chr(126)) return  $+ %nlow $+ $chr(126) $+ 14 $+ $nick
elseif ($left(%nop2,1) == $chr(38)) return  $+ %nlad $+ $chr(38) $+ 14 $+ $nick
elseif ($left(%nop2,1) == $chr(64)) return  $+ %nlop $+ $chr(64) $+ 14 $+ $nick
elseif ($left(%nop2,1) == $chr(37)) return  $+ %nlha $+ $chr(37) $+ 14 $+ $nick
elseif ($left(%nop2,1) == $chr(43)) return  $+ %nlvo $+ $chr(43) $+ 14 $+ $nick
else { return $nick }
}

alias chkc2 {
set -l %cni $checknick2
if ($active ischan) {
return %cni
}
else {
return $nick
}
}

Last edited by Doctor_Souza; 11/12/17 12:39 AM.
Re: if else [Re: Doctor_Souza] #261913 11/12/17 04:12 AM
Joined: Jan 2004
Posts: 1,229
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,229
Generally you want to post your code using the # button and select 'code' so the code is easier to see instead of getting mashed to the left in a proportional font. You can use 'preview post' to make sure you get it looking reasonably well.

Also, you were vague as to what 'sometimes' means. You didn't say how this was called, such as 100% guarantee that it's only called from within an event where $nick is defined, and not in a timer or a right-click menu.

Bugs are easier to nail down if you include some echo commands to the status window which include $scriptline $nopath($script) and contain variables etc, so you can triangulate the error. For example, an echo at the top of the alias can verify whether $nick is actually defined, and whether %nop2 is set correctly too.

Also, if you put an echo right above your 'return' commands, so you can identify which of the 2 returns might be the one that has the error, or whether they both can generate the error.