The /breplace command can be used to replace an ASCII value by another value in a binary variable. Multiple replacements are allowed.
Synopsis
/breplace &binvar <oldvalue> <newvalue> [oldvalue newvalue...]
Switches
None
Parameters
- <oldvalue> - The old ASCII value to replaced (decimal 0-255)
- <newvalue> - The new ASCII value to replace the old one (decimal 0-255)
Note: This replaces individual bytes and does not allow replacing multi-byte patterns with new multi-byte patterns.
Note: Bytes are replaced only once, even if the new_value is the old_value for the next old/new pair.
Note: You can have multiple old/new number pairs, and if the count of numbers is an odd number greater than 2, the last unpaired number is ignored.
Note: You cannot breplace within a portion of a binary &string unless you bcopy that section to a &temp where you perform the breplace then bcopy &temp back to the original &string/position.
Example
Alias Example { ;Create a binary variable set it to "Hello World" bset -t &Example 1 Hello World ;Replace e (ASCII value 101) with 3 (ASCII value 51) breplace &Example 101 51 ;Echo our new string echo -a $bvar(&Example,1,$bvar(&Example,0)).text }
The above example will output:
H3llo World
Note that long strings can be replaced. The replace is on the entire token - not finding the 0 within the 10: //bset &a 7654321 10 | echo -a $bvar(&a,7654300-) | breplace &a 0 1 | echo -a $bvar(&a,7654300-) shows the last 22 bytes changing: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10
The replacement is not recursive, it does not find the 33's changed to 44's when it changes the existing 44's to 45's //bset &a 1 33 33 44 44 55 | echo -a $bvar(&a,1-) | breplace &a 33 44 44 45 | echo -a $bvar(&a,1-) returns: 44 44 45 45 55
The number of from/to byte pairs is an odd number greater than 2, so the last unpaired number is ignored without reporting an error: //bset &a 1 13 10 13 10 99 | breplace &a 10 13 13 10 99 | echo -a $bvar(&a,1-) returns: 10 13 10 13 99
Compatibility
Added: mIRC v5.6
Added on: 03 Jun 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
See also