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

(Switches)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{mirc title|/bwrite Command}}
 
{{mirc title|/bwrite Command}}
The '''/bwrite command''' can be used to write a specified amount of bytes from the string/buffer to a given file starting at the start_pos position.
+
The '''/bwrite''' command can be used to write a specified amount of bytes from the string/buffer to a given file starting at the start_pos position.
  
 
'''Note''': the starting position is 0, not 1.
 
'''Note''': the starting position is 0, not 1.
  
 
== Synopsis ==
 
== Synopsis ==
  /bwrite -act <filename> <start_pos> [length] <text|%var|&binvar>
+
  /bwrite -act <filename> <start_pos> <length> <text|%var|&binvar>
 +
 
 +
 
 +
'''Note''': If you pass a %var to /bwrite, if the content of that %var is a %variable itself, of if the first token of %var is a %variable itself, the content of %variable is used and no tokenization on %variable occurs, effectively preserving spaces. See the example
  
 
== Switches ==
 
== Switches ==
* '''-t''' - Treats everything as plain text (i.e. binary variables are not evaluated)
+
* '''-t''' - Treats everything as plain text (i.e. $identifiers and %variables (but not contents of %variables) are evaluated, but binary variables are not evaluated, are treated as text strings beginning with &) This switch is needed if literal string begins with &  or string within %var begins with & or % characters.
* '''-c''' - Chops the file at the end of the written data (if your current binvar is 10 bytes and you write 3 bytes at position 3, the resulting binvar is 6 in lenght)
+
* '''-c''' - Chops the file at the end of the written data (if your current disk file is 10 bytes and you write 3 bytes at position 3 (4th byte), the resulting disk file's filesize is 6 because the 3 bytes were written as the 4th through 6th bytes of the file)
 
* '''-a''' - Disables UTF-8 encoding of characters in the range 0-255, as long as the line contains no characters > 255
 
* '''-a''' - Disables UTF-8 encoding of characters in the range 0-255, as long as the line contains no characters > 255
  
 
== Parameters ==
 
== Parameters ==
 
* '''<filename>''' - the file name to be modified
 
* '''<filename>''' - the file name to be modified
* '''<start_pos>''' - the position in the file to start writing at, starts a 0
+
* '''<start_pos>''' - the position in the file to start writing at. First byte of the file is 0. Using -1 appends data to the end of existing file.
* '''[length]''' - Length of the data to be written
+
* '''[length]''' - Length of the data to be written. Using -1 writes entire length of source text or variable.
 
* '''<text|%var|&binvar>''' - data to be written to the file
 
* '''<text|%var|&binvar>''' - data to be written to the file
  
Line 23: Line 26:
 
;Replace "there!" with "world!"
 
;Replace "there!" with "world!"
 
/bwrite file.txt 6 world!</syntaxhighlight>
 
/bwrite file.txt 6 world!</syntaxhighlight>
 +
 +
<syntaxhighlight lang="mIRC">
 +
//var %b a $chr(32) b | var %a % $+ b | bwrite -c test 0 -1 %a | loadbuf -a test
 +
displays "a  b"
 +
because the first token in %a is a variable (%b). Adding the -t switch  would have instead written the literal string "%b".
 +
</syntaxhighlight>
  
 
== Compatibility ==
 
== Compatibility ==
Line 28: Line 37:
  
 
== See also ==
 
== See also ==
* [[List of commands - mIRC|List of commands]]
 
* [[List of identifiers - mIRC|List of identifiers]]
 
 
* {{mIRC|$bvar}}
 
* {{mIRC|$bvar}}
 +
* {{mIRC|/bset}}
 +
* {{mIRC|/bcopy}}
 
* {{mIRC|/bread}}
 
* {{mIRC|/bread}}
 
* {{mIRC|/breplace}}
 
* {{mIRC|/breplace}}
* {{mIRC|/bset}}
 
 
* {{mIRC|/btrunc}}
 
* {{mIRC|/btrunc}}
 
* {{mIRC|/bunset}}
 
* {{mIRC|/bunset}}
 +
* {{mIRC|$bfind}}
 
* {{mIRC|/fwrite}}
 
* {{mIRC|/fwrite}}
 
* {{mIRC|/write}}
 
* {{mIRC|/write}}
 +
* [[List of commands - mIRC|List of commands]]
 +
* [[List of identifiers - mIRC|List of identifiers]]
 +
 
{{mIRC command list}}
 
{{mIRC command list}}
  
 
[[Category:mIRC commands|bwrite command - mIRC]]
 
[[Category:mIRC commands|bwrite command - mIRC]]

Latest revision as of 17:47, 2 May 2023

The /bwrite command can be used to write a specified amount of bytes from the string/buffer to a given file starting at the start_pos position.

Note: the starting position is 0, not 1.

Synopsis[edit]

/bwrite -act <filename> <start_pos> <length> <text|%var|&binvar>


Note: If you pass a %var to /bwrite, if the content of that %var is a %variable itself, of if the first token of %var is a %variable itself, the content of %variable is used and no tokenization on %variable occurs, effectively preserving spaces. See the example

Switches[edit]

  • -t - Treats everything as plain text (i.e. $identifiers and %variables (but not contents of %variables) are evaluated, but binary variables are not evaluated, are treated as text strings beginning with &) This switch is needed if literal string begins with & or string within %var begins with & or % characters.
  • -c - Chops the file at the end of the written data (if your current disk file is 10 bytes and you write 3 bytes at position 3 (4th byte), the resulting disk file's filesize is 6 because the 3 bytes were written as the 4th through 6th bytes of the file)
  • -a - Disables UTF-8 encoding of characters in the range 0-255, as long as the line contains no characters > 255

Parameters[edit]

  • <filename> - the file name to be modified
  • <start_pos> - the position in the file to start writing at. First byte of the file is 0. Using -1 appends data to the end of existing file.
  • [length] - Length of the data to be written. Using -1 writes entire length of source text or variable.
  • <text|%var|&binvar> - data to be written to the file

Example[edit]

;Write some text to a file at beginning of the file
/bwrite file.txt 0 hello there!
;Replace "there!" with "world!"
/bwrite file.txt 6 world!
//var %b a $chr(32) b | var %a % $+ b | bwrite -c test 0 -1 %a | loadbuf -a test
displays "a  b"
because the first token in %a is a variable (%b). Adding the -t switch  would have instead written the literal string "%b".

Compatibility[edit]

Added: mIRC v5.3
Added on: 13 Dec 1997
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also[edit]


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