mIRC Home    About    Download    Register    News    Help

Print Thread
#57648 26/10/03 03:11 PM
Joined: Jul 2003
Posts: 733
M
MTec89 Offline OP
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Jul 2003
Posts: 733
Post deleted by MTec89

#57649 26/10/03 03:13 PM
Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015

#57650 26/10/03 03:23 PM
Joined: Jul 2003
Posts: 733
M
MTec89 Offline OP
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Jul 2003
Posts: 733
well, i didnt want everyone to know what i was making and take my idea :tongue: but i need help. mirc doesnt save this alias when i try to enter it.
Code:
bin $replacecs($1-,a,01100001,b,01100010,c,01100011d,01100100,e,01100101,f,01100110,g,01100111,h,01101000,i,01101001,j,01101010,k,01101011,l,01101100,m,01101101,n,01101110,o,01101111,p,01110000,q,01110001,r,01110010,s,01110011,t,01110100,u,01110101,v,01110110,w,01110111,x,01111000,y,01111001,z,01111010,A,01000001,B,01000010,C,01000011,D,01000100,E,01000101,F,01000110,G,01000111,H,01001000,I,01001001,J,01001010,K,01001011,L,01001100,M,01001101,N,01001110,O,01001111,P,01010000,Q,01010001,R,01010010,S,01010011,T,01010100,U,01010101,V,01010110,W,01010111,X,01011000,Y,01011001,Z,01011010,1,00110001,2,00110010,3,00110011,4,00110100,5,00110101,6,00110110,7,00110111,8,00111000,9,00111001,0,00110000`,01100000,~,01111110,!,00100001,@,01000000,#,00100011,$,00100100,%,00100101,^,01011110,&,00100110,*,00101010,$chr(41),00101001,$chr(40),00101000,$chr(44),00101100,$chr(124),01111100,$chr(32),00100000,$chr(123),01111011,$chr(125),01111101,-,00101101,_,01011111,=,00111101,+,00101011,\,01011100,[,01011011,],01011101,;,00111011,:,00111010,',00100111,",00100010,<,00111100,>,00111110,.,00101110,/,00101111,?,00111111)

#57651 26/10/03 03:48 PM
P
pheonix
pheonix
P
bin $base($1-,10,2)
wink

#57652 26/10/03 04:06 PM
Joined: Jul 2003
Posts: 733
M
MTec89 Offline OP
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Jul 2003
Posts: 733
im trying to use my own alias instead of that one

#57653 26/10/03 04:10 PM
P
pheonix
pheonix
P
yours won't work...
a = 1010
b = 1011
ab = 1101111
----------------
your method
ab = 10101011

#57654 26/10/03 05:30 PM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
try this:

Code:
/chr_to_bin {
  var %dec = $asc($1)

  var %p = 128
  while (%p > 0) {
    if (%dec >= %p) var %bin = %bin $+ 1, %dec = %dec - %p
    else var %bin = %bin $+ 0
    var %p = $int($calc(%p / 2))
  }

  return %bin
}


you can either use $replacecs, or loop through each letter..

Code:
var %l = 1
while ($mid($1-, %l, 1)) {
  var %result = %result $chr_to_bin($ifmatch)
  /inc %l
}


abc = 01100001 01100010 01100011

#57655 26/10/03 06:16 PM
P
pheonix
pheonix
P
$chr_to_bin(a) = 01100001
$chr_to_bin(b) = 01100010
$base(a,10,2) = 1010
$base(b,10,2) = 1011
which one's right? ;\

#57656 26/10/03 06:19 PM
Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
Both are, but King's is what he's after I think.

Yours:
a = 10 = 1010
b = 11 = 1011

Kings:
$asc(a) = 97 = 01100001
$asc(b) = 98 = 01100010


#57657 26/10/03 06:28 PM
Joined: Jul 2003
Posts: 733
M
MTec89 Offline OP
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Jul 2003
Posts: 733
elseif (%binary == on) {
if (left($1,1) == /) && ($1 != /notice) && ($1 != /me) { return $1- }
elseif ($1 == /me) { describe # $replace($1-,$1-,$bin($1-)) }
elseif ($1 == /notice) { notice $2 $replace($2-,$1-,$bin($2-)) }
else { msg $active $replace($2-,$2-,$bin($2-)) }
}

alias bin {
var %dec = $asc($1)
var %p = 128
while (%p > 0) {
if (%dec >= %p) var %bin = %bin $+ 1, %dec = %dec - %p
else var %bin = %bin $+ 0
var %p = $int($calc(%p / 2))
}
return %bin
}

i get
* /msg: insufficient parameters (line 24, txtsuite.mrc)
and then the normal text is displayed

line 24 is:
else { msg $active $replace($2-,$2-,$bin($2-)) }

how do i make it change all text, just plain /return $bin(a s d f g) only affects a

#57658 26/10/03 06:33 PM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
Code:
/chr_to_bin {
  var %dec = $asc($1)

  var %p = 128
  while (%p > 0) {
    if (%dec >= %p) var %bin = %bin $+ 1, %dec = %dec - %p
    else var %bin = %bin $+ 0
    var %p = $int($calc(%p / 2))
  }

  return %bin
}

/binary {
  var %l = 1
  while ($mid($1-, %l, 1)) {
    var %str = %str $chr_to_bin($ifmatch)
    /inc %l
  }
  return %str
}


//say $binary(This is a test)

#57659 26/10/03 06:41 PM
Joined: Jul 2003
Posts: 733
M
MTec89 Offline OP
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Jul 2003
Posts: 733
edited:
ok i fixed everything, but how do i remove the space between the letteres that wasnt originally spaced?

Last edited by MTec89; 26/10/03 06:52 PM.
#57660 26/10/03 09:27 PM
Joined: Jul 2003
Posts: 733
M
MTec89 Offline OP
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Jul 2003
Posts: 733
( i couldnt edit the post before this one)
ok i fixed everything, but how do i remove the space between the letteres that wasnt originally spaced?
like hello is:
01101000 01100101 01101100 01101100 01101111
instead of
0110100001100101011011000110110001101111

but i still want spaces to be binary like this:
hello there
0110100001100101011011000110110001101111001000000111010001101000011001010111001001100101

#57661 26/10/03 09:30 PM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
var %str = %str $chr_to_bin($ifmatch)
turns into
var %str = %str $+ $chr_to_bin($ifmatch)

#57662 26/10/03 09:33 PM
Joined: Jul 2003
Posts: 733
M
MTec89 Offline OP
Hoopy frood
OP Offline
Hoopy frood
M
Joined: Jul 2003
Posts: 733
worked:) Thx

#57663 28/10/03 12:08 AM
Joined: Feb 2003
Posts: 2,737
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,737
Only to answer your original question, though I'm sure the suggestions above are better than this...
To get this to save in your script, you need to break it into multiple lines using $&.

replacecs($1-,a,01100001,b,01100010,c,01100011,d,01100100,e,01100101,f,01100110, $&
g,01100111,h,01101000,i,01101001,j,01101010,k,01101011,l,01101100,m,01101101, $&
n,01101110,o,01101111,p,01110000,q,01110001,r,01110010,s,01110011,t,01110100, $&
u,01110101,v,01110110,w,01110111,x,01111000,y,01111001,z,01111010,A,01000001, $&
B,01000010,C,01000011,D,01000100,E,01000101,F,01000110,G,01000111,H,01001000, $&
I,01001001,J,01001010,K,01001011,L,01001100,M,01001101,N,01001110,O,01001111, $&
P,01010000,Q,01010001,R,01010010,S,01010011,T,01010100,U,01010101,V,01010110, $&
W,01010111,X,01011000,Y,01011001,Z,01011010,1,00110001,2,00110010,3,00110011, $&
4,00110100,5,00110101,6,00110110,7,00110111,8,00111000,9,00111001,0,00110000, $&
`,01100000,~,01111110,!,00100001,@,01000000,#,00100011,$,00100100,%,00100101, $&
^,01011110,&,00100110,*,00101010,$chr(41),00101001,$chr(40),00101000, $&
$chr(44),00101100,$chr(124),01111100,$chr(32),00100000,$chr(123),01111011, $&
$chr(125),01111101,-,00101101,_,01011111,=,00111101,+,00101011,\,01011100, $&
[,01011011,],01011101,;,00111011,:,00111010,',00100111,",00100010,<,00111100, $&
>,00111110,.,00101110,/,00101111,?,00111111)


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#57664 28/10/03 06:01 AM
I
Iori
Iori
I
Or you could just use $base in the loop and avoid that chr_to_bin alias altogether. smile
Code:
alias bin {
  var %i = 1
  while $mid($1-,%i,1) {
    var %r = %r $+ $base($asc($ifmatch),10,2,8)
    inc %i
  }
  return %r
}

#57665 30/10/03 02:56 AM
Joined: Aug 2003
Posts: 325
W
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
Try this:

---
/d2b {
%d2b = $strip($1-)
unset %bin
while ( %d2b ) {
if $asc(%d2b) = 32 { set %bin $+(%bin,$chr(160)) }
else { set %bin $+(%bin,$base($asc(%d2b),10,2,8)) }
%d2b = $mid(%d2b,2)
}
return %bin
}
---
//echo binary: $d2b(Hello with spaces)

will produce:
binary: 0100100001100101011011000110110001101111 01110111011010010111010001101000 011100110111000001100001011000110110010101110011

If you don't want spaces, then remove that line that checks for ascii value 32, or change the 160 at the end to 32.
Easy to make it the way you want.
smile
Have fun


Link Copied to Clipboard