From WikiChip
Difference between revisions of "mirc/commands/breplace"
< mirc‎ | commands

m (Bot: de-linking old mIRC menu)
(Add'l syntax and examples)
Line 1: Line 1:
 
{{mirc title|/breplace Command}}
 
{{mirc title|/breplace Command}}
The '''/breplace command''' can be used to replace an ASCII value by another value in a binary variable. Multiple replacements are allowed.
+
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>
  
<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 ==
* [[List of commands - mIRC|List of commands]]
 
* [[List of identifiers - mIRC|List of identifiers]]
 
 
* {{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


v · d · e mIRC commands list

A /abook, /action, /add, /ajinvite, /alias, /aline, /ame, /amsg, /anick, /aop, /auser, /auto, /autojoin, /avoice, /away

B /background, /ban, /bcopy, /beep, /bindip, /bread, /break, /breplace, /bset, /btrunc, /bunset, /bwrite

C /channel, /clear, /clearall, /clearial, /cline, /clipboard, /close, /closechats, /closedccs, /closefserves, /closemsg, /cnick, /color, /colour, /comclose, /comlist, /commands, /comopen, /comreg, /continue, /copy, /creq, /ctcp, /ctcpreply, /ctcps

D /dcc, /dccserver, /dde, /ddeserver, /debug, /dec, /describe, /dialog, /did, /didtok, /disable, /disconnect, /dlevel, /dline, /dll, Template:mIRC/donotdisturb, /dns, /dqwindow, /drawcopy, /drawdot, /drawfill, /drawline, /drawpic, /drawrect, /drawreplace, /drawrot, /drawsave, /drawscroll, /drawsize /drawtext

E /ebeeps, /echo, /editbox, /else, /elseif, /emailaddr, /enable, /events, /exit

F /fclose, /filter, /findtext, /finger, /firewall, /flash, /flist, /flood, /flush, /flushini, /fnord, /font, /fopen, /fseek, /fsend, /fserve, /fullname, /fupdate, /fwrite

G /ghide, /gload, /gmove, /gopts, /goto, /gplay, /gpoint, /gqreq, /groups, /gshow, /gsize, /gstop, /gtalk, /gunload, /guser

H /hadd, /halt, /haltdef, /hdec, /hdel, /help, /hfree, /hinc, /hload, /hmake, /hotlink, /hop, /hsave

I /ial, /ialclear, /ialmark, /identd, /if, /ignore, /iline, /inc, /iuser

J /join

L /leave, /linesep, /links, /list, /load, /loadbuf, /localinfo, /log, /logview

M /maxdepth, /mdi, /me, /menubar, /mkdir, /mnick, /mode, /msg

N /noop, /notice, /notify

O /onotice, /omsg

P /pareline, /part, /partall, /pdcc, /perform, /play, /playctrl, /pop, /protect, /proxy, /pvoice

Q /qme, /qmsg, /query, /queryrn, /quit, /quote

R /raw, /registration, /reload, /remini, /remote, /remove, /rename, /renwin, /reseterror, /resetidle, /return, /returnex, /rlevel, /rline, /rmdir, /run, /ruser

S /save, /savebuf, /saveini, /say, /scid, /scon, /server, /set, /setlayer, /showmirc, /signal, /sline, /sockaccept, /sockclose, /socklist, /socklisten, /sockmark, /sockopen, /sockpause, /sockread, /sockrename, /sockudp, /sockwrite, /sound, /speak, /splay, /sreq, /strip, /switchbar

T /timer, /timestamp, /tip, /tips, /titlebar, /tnick, /tokenize, /toolbar, /topic /tray, /treebar

U /ulist, /unload, /unset, /unsetall, /updatenl, /url, /username, /uwho

V /var, /vcadd, /vcmd, /vcrem, /vol

W

X /xyzzy