m (Bot: de-linking old mIRC menu) |
Maroonbells (talk | contribs) (Add'l syntax and examples) |
||
Line 1: | Line 1: | ||
{{mirc title|/breplace Command}} | {{mirc title|/breplace Command}} | ||
− | The '''/breplace | + | The '''/breplace''' command can be used to replace an ASCII value by another value in a binary variable. Multiple replacements are allowed. |
== Synopsis == | == Synopsis == | ||
Line 9: | Line 9: | ||
== Parameters == | == Parameters == | ||
− | * '''<oldvalue>''' - The old ASCII value to replaced | + | * '''<oldvalue>''' - The old ASCII value to replaced (decimal 0-255) |
− | * '''<newvalue>''' - The new ASCII value to replace the old one | + | * '''<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.<br /> | |
+ | '''Note:''' Bytes are replaced only once, even if the new_value is the old_value for the next old/new pair.<br /> | ||
+ | '''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.<br /> | ||
+ | '''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 == | == Example == | ||
<syntaxhighlight lang="mIRC">Alias Example { | <syntaxhighlight lang="mIRC">Alias Example { | ||
Line 25: | Line 28: | ||
The above example will output: | The above example will output: | ||
+ | <pre>H3llo World</pre> | ||
− | < | + | <syntaxhighlight lang="mIRC"> |
+ | 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 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | <syntaxhighlight lang="mIRC"> | ||
+ | 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 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | <syntaxhighlight lang="mIRC"> | ||
+ | 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 | ||
+ | </syntaxhighlight> | ||
== Compatibility == | == Compatibility == | ||
Line 32: | Line 54: | ||
== See also == | == See also == | ||
− | |||
− | |||
* {{mIRC|$bvar}} | * {{mIRC|$bvar}} | ||
* {{mIRC|$bfind}} | * {{mIRC|$bfind}} | ||
Line 42: | Line 62: | ||
* {{mIRC|/btrunc}} | * {{mIRC|/btrunc}} | ||
* {{mIRC|/bcopy}} | * {{mIRC|/bcopy}} | ||
+ | * [[List of commands - mIRC|List of commands]] | ||
+ | * [[List of identifiers - mIRC|List of identifiers]] | ||
{{mIRC command list}} | {{mIRC command list}} | ||
[[Category:mIRC commands|breplace command - mIRC]] | [[Category:mIRC commands|breplace command - mIRC]] |
Revision as of 03:36, 11 January 2018
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