From WikiChip
Editing mirc/commands/bread

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{mirc title|/bread Command}}
 
 
The '''/bread command''' can be used to read a certain amount of bytes from a file at a given position and store it in a binary variable.
 
The '''/bread command''' can be used to read a certain amount of bytes from a file at a given position and store it in a binary variable.
  
'''Note''': the beginning of the file is position 0.
+
The beginning of the file is position 0.
  
 
== Synopsis ==
 
== Synopsis ==
  /bread -ta <filename> <bytepos> <numbytes> <&bvar>
+
  /bread -t <filename> <bytepos> <numbytes> <&bvar>
  
 
== Switches ==
 
== Switches ==
* '''-t''' - Reads data preceding the first encountered line ending or EOF, interpreting as UTF8 text
+
* '''-t''' - Reads data up to the next CR/LF
* '''-a''' - Modifier for -t switch, codepoints 128-255 are not encoded to UTF8 if no codepoint above 255 is found
 
  
 
== Parameters ==
 
== Parameters ==
* '''<filename>''' - The file name to read from. Double quotes needed if string contains space
+
* '''<filename>''' - The file name to read from.
* '''<bytepos>''' - The starting byte position, '''remember, this starts at 0, not 1'''.
+
* '''<bytepos>''' - The starting byte position.
 
* '''<numbytes>''' - The length (bytes) to be read.
 
* '''<numbytes>''' - The length (bytes) to be read.
* '''<&bvar>''' - The binary variable to store the data in. If &binvar already exists, contents are replaced.
+
* '''<&bvar>''' - The binary variable to store the data in.
  
 
== Example ==
 
== Example ==
<source lang="mIRC">;noop $copyExample(FileA,FileB)
+
<syntaxhighlight lang="mIRC">;noop $copyExample(FileA,FileB)
 
alias copyExample {
 
alias copyExample {
 
   ;Read the whole file into a binary variable
 
   ;Read the whole file into a binary variable
Line 25: Line 23:
 
   ;Write the bytes form the binary variable to a file
 
   ;Write the bytes form the binary variable to a file
 
   bwrite $qt($2) 0 -1 &tempFile
 
   bwrite $qt($2) 0 -1 &tempFile
}</source>
+
}</syntaxhighlight>
  
<source lang="mIRC">
+
== Compatibility ==
Using -t switch:
+
Added: mIRC v5.3
Line ending is defined as data preceding
 
  
//bset &v 1 233 | bwrite -c test.dat 0 &v | bread test.dat 0 9 &v2 | echo -a $bvar(&v2,1-)
+
Added On: 13/12/97
result: 233 because no switch used
 
  
//bset &v 1 233 | bwrite -c test.dat 0 &v | bread -t test.dat 0 9 &v2 | echo -a $bvar(&v2,1-)
 
result: 195 169 because -t used without -a interprets as UTF8 encoding of codepoint 233
 
  
//bset &v 1 233 | bwrite -c test.dat 0 &v | bread -ta test.dat 0 9 &v2 | echo -a $bvar(&v2,1-)
 
result: 233 because -ta used AND data read doesn't contain codepoint 256+
 
  
//bset &v 1 226 156 148 233 | bwrite -c test.dat 0 &v | bread -ta test.dat 0 9 &v2 | echo -a $bvar(&v2,1-)
 
result: 226 156 148 195 169 because data read contains codepoint 10004
 
* If bread's offset changed from 0 to 3, result is 233 because the read portion of the line doesn't contain the codepoint above 255
 
</source>
 
 
<source lang="mIRC">//bread $qt($mircexe) 0 $file($mircexe).size &v | echo -a $md5(&v,1) is the same as $md5($mircexe,2) if enough memory available for binvar</source>
 
 
== Compatibility ==
 
{{mIRC compatibility|5.3}}
 
 
== See also ==
 
== See also ==
 +
* [[List of commands - mIRC|List of commands]]
 +
* [[List of identifiers - mIRC|List of identifiers]]
 
* {{mIRC|$file}}
 
* {{mIRC|$file}}
* {{mIRC|/bcopy}}
 
* {{mIRC|/breplace}}
 
 
* {{mIRC|/bset}}
 
* {{mIRC|/bset}}
* {{mIRC|/btrunc}}
 
 
* {{mIRC|/bunset}}
 
* {{mIRC|/bunset}}
 
* {{mIRC|/bwrite}}
 
* {{mIRC|/bwrite}}
* {{mIRC|$bvar}}
+
{{mIRC command list}}
* {{mIRC|$bfind}}
+
 
 +
[[Category:MIRC commands]]

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)