I will eventually be adding a feature to either
A) Save links of your old posts and check them when clicked on and collect the data posted and display it, or remove the link from your history if it's been deleted.
B) Allows you to supply a link and it will collect the data posted from the link and display it, or tell you if it's been deleted.
Just a suggestion, the use of global variables should be used. Locals would have sufficed.
Also for longtintoascii, in the if instead of needing to use calc just use
if (8 \\ $len($1)) { echo -sa * /longbintoascii SyntaxError: Invalid Input | return }
aswell as for your binary2ascii all those if statements could be avoided using a simple loop.
var %a = 1,%b
while ($mid($1,%a,1) != $null) {
inc %b $calc( $v1 * 2 ^ ( 8 - %a ) )
inc %a
}
var %t = $+(%t,$iif($chr(%b) == $chr(32),$str($chr(1),3),$v1)
var %b
If you don't like the multiple chr(1)'s in place of spaces you can do it another way that's suitable for you, i simply chose that cause well, it's very unlikely that there will be 3 chr(1)'s consecutive in a string being processed.
Same goes for your ascii2binary
var %a = 1,%b = 1
while ($asc($mid($1-,%a,1)) != $null) {
var %x = $v1
while (%x > 0) {
var %y = $iif(2 \\ $v1,1,0) $+ %y,%x = $floor($calc(%x / 2))
}
var %bin = $+(%bin,$str(0,$calc(8 - $len(%y))),%y)
inc %a
}
Here are my versions of your code:
/*
* Binary -> Decimal
*/
todec {
if (8 // $len($$1-)) {
noop $regex(dec,$$1-,/([01]{8})/g)
var %a = 1,%b,%t
while ($regml(dec,%a)) {
var %c = 1,%d = $v1
while ($mid(%d,%c,1) != $null) {
inc %b $calc( $v1 * 2 ^ ( 8 - %c ) )
inc %c
}
var %t = $+(%t,$iif($chr(%b) != $chr(32),$v1,$str($chr(1),3)))
var %b
inc %a
}
return $replace(%t,$str($chr(1),3),$chr(32))
}
return
}
/*
* Decimal -> Binary
*/
binary {
var %a = $len($1-)
while (%a) {
var %b = $tobin($asc($mid($1-,%a,1))) $+ %b
dec %a
}
return %b
}
tobin {
var %x = $1-
while (%x > 0) {
var %y = $iif(2 \\ %x,1,0) $+ %y
var %x = $floor($calc(%x / 2))
}
return $+($str(0,$calc(8- $len(%y))),%y)
}
@Sunslayer;
$regsubex($1-,/(\w)(.+?)(\W)/g,$+($upper(\1),$lower(\2),\3))
will capitalize the first letter and make the rest of the word lowercase for each word which looks better imo
I'm not really sure why you had to use (.+)(\W|\b). You should have only needed two backreferences at most.
alias _upper return $regsubex($1-,/(\w)(\w+)/g,$upper(\1) $+ $lower(\2))
Personally i wouldn't have even used regex at all. At the upmost i would have done something like.
on *:TEXT:$(* $me $+ ? *):*:{
if (!$window(@HighlightLog)) { window -ez @HighLightLog }
if (!$hget(HLFlood $+ $network,$wildsite)) {
hadd -mz $+(HLFlood,$network) $wildsite 30
aline -hi20 @HighlightLog Highlight - $nick ( $+ $wildsite $+ ) - $+($iif(#,#,Query),@,$network) - $timestamp $$1-
}
}
The reason i would use hashtables is because if you EXIT mIRC the variables are left in the VAR tab if the unset isn't triggered. Atleast hash tables are deleted automatically when you EXIT unless you have a method of saving them on exit. If you do you can simple exclude them from your method. That's just my two cents.
It doesn't look like you have support for ranges or negative values.
IE:
gettok("hello there what's up",2-3," ") -> there what's
gettok("hello there what's up",-1," ") -> up
Maybe something you could look into. I had made a gettok that supported ranges a while back. i'll try and find it or remake it .
EDIT:
I took the liberty of doing my best to remake what i had and this is what i came up with.
function gettok($string,$n,$c) {
if(is_numeric($c)) {
$c = chr($c);
}
$tok = explode($c,$string);
if($n==0) {
return count($tok);
}
if($n < 0) {
$n = count($tok)-$n;
}
if(@preg_match("#(\d+)-(\d+)?#",$n,$range)) {
$text = "";
if(count($range[1])==1) {
$r1 = $range[1][0]-1;
$r2 = count($tok);
} else {
$r1 = $range[1][0]-1;
$r2 = $range[1][1];
}
while($r1<$r2) {
$text .= $tok[$r1];
$r1++;
}
return $text;
}
if(empty($tok[$n-1])) {
return FALSE;
} else {
return $tok[$n-1];
}
}