mIRC Home    About    Download    Register    News    Help

Print Thread
#87197 17/06/04 11:25 AM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
I was wondering on how you would go about making a binary encoder/decoder command (eg: !binary-en Im talking in binary.) Then it would reply with:
<Nick> Binary Encode: 010010010110110100100000011101000110000101101100011010110110100101101110011001110010000001101001011011100010000001100010011010010110111001100001011100100111100100101110
(which thats really what it says in binary)
--
and you get the decode command (eg: !binary-de)
I don't know how much of it you can tell me without giving me the full script (becasue I don't know how many people out there actually know binary) Thanks for any help in advance smile

#87198 17/06/04 01:11 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
for each character: (use $mid to get it)
- get it's ascii value -> $asc
- convert it to binary -> $base(xx,10,2)
- make sure it's 8 digits long (put 0's in front of it, or add 256 to the $asc value before and then take only last 8 digits ($left or $right)
- append it to output string
msg the output

That's about it, but be careful because each character will take up 8 characters after conversion, so you can only write very short lines (25 characters) before it gets chopped off

To decode it:
chop binary stuff in 8 character chunks ($mid again)
use $chr($base(bbbbbbbb,2,10)) to get the ascii character and append it to output

you can search the help file for alle the $identifiers used for more info

#87199 17/06/04 01:28 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Quote:
- convert it to binary -> $base(xx,10,2)
- make sure it's 8 digits long (put 0's in front of it, or add 256 to the $asc value before and then take only last 8 digits ($left or $right)

This can be done in one step with $base(xx,10,2,8)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#87200 17/06/04 02:06 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
* Kelder does what he tells other people to: type /help and read blush

#87201 17/06/04 03:00 PM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
Thanks for the help smile


Link Copied to Clipboard