Project

General

Profile

Bwrite » History » Version 3

Per Amundsen, 05/09/2017 09:31 PM

1 1 Per Amundsen
_Added in 1.9.0_
2
3 3 Per Amundsen
*/bwrite [-ta] <filename> <S> [N] <text|%var|&binvar>*
4 1 Per Amundsen
5
Writes [N] bytes from <text|%var|&binvar> to the file starting at byte position <S> or 0, any existing information at this position is overwritten.
6
7
*Switches*
8
9
-t - Treat <text|%var|&binvar> as plain text.
10 3 Per Amundsen
-a - TODO
11 1 Per Amundsen
12
*Parameters*
13
14
<filename> - File to modify.
15
<S> - Byte position in the file to start writing to.
16
[N] - Byte count from <text|%var|&binvar> to write.
17 2 Per Amundsen
<text|%var|&binvar> - Text/%variable/&binvar to write to file.
18 1 Per Amundsen
19
*Example*
20
21
<pre>
22
alias example {
23
  ;Write some text to a file at beginning of the file
24
  /bwrite file.txt 0 hello there!
25
26
  ;Read the binary data into binary variable &tempfile
27
  /bread $qt(file.txt) 0 $file(file.txt).size &tempfile
28
29
  ;Print the binary variable data as text, outputs 'Hello there!'
30
  echo -ag $bvar(&tempfile, 1-).text
31
  
32
  ;Replace "there!" with "world!"
33
  /bwrite file.txt 6 world!
34
35
  ;Read the binary data into binary variable &tempfile
36
  /bread $qt(file.txt) 0 $file(file.txt).size &tempfile
37
38
  ;Print the binary variable data as text, outputs 'Hello world!'
39
  echo -ag $bvar(&tempfile, 1-).text
40
}
41
</pre>