Bwrite » History » Version 2
Per Amundsen, 02/09/2014 12:35 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | */bwrite [-t] <filename> <S> [N] <text|%var|&binvar>* |
||
4 | |||
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 | |||
11 | *Parameters* |
||
12 | |||
13 | <filename> - File to modify. |
||
14 | <S> - Byte position in the file to start writing to. |
||
15 | [N] - Byte count from <text|%var|&binvar> to write. |
||
16 | 2 | Per Amundsen | <text|%var|&binvar> - Text/%variable/&binvar to write to file. |
17 | 1 | Per Amundsen | |
18 | *Example* |
||
19 | |||
20 | <pre> |
||
21 | alias example { |
||
22 | ;Write some text to a file at beginning of the file |
||
23 | /bwrite file.txt 0 hello there! |
||
24 | |||
25 | ;Read the binary data into binary variable &tempfile |
||
26 | /bread $qt(file.txt) 0 $file(file.txt).size &tempfile |
||
27 | |||
28 | ;Print the binary variable data as text, outputs 'Hello there!' |
||
29 | echo -ag $bvar(&tempfile, 1-).text |
||
30 | |||
31 | ;Replace "there!" with "world!" |
||
32 | /bwrite file.txt 6 world! |
||
33 | |||
34 | ;Read the binary data into binary variable &tempfile |
||
35 | /bread $qt(file.txt) 0 $file(file.txt).size &tempfile |
||
36 | |||
37 | ;Print the binary variable data as text, outputs 'Hello world!' |
||
38 | echo -ag $bvar(&tempfile, 1-).text |
||
39 | } |
||
40 | </pre> |