Difference between revisions of "Bset"
m (corrected binary files -link) |
m |
||
Line 13: | Line 13: | ||
bset &test 1 65 | bset &test 1 65 | ||
bset &test 5 66 | bset &test 5 66 | ||
− | echo -a [[$bvar]](&test,1,5) | + | [[echo]] -a [[$bvar]](&test,1,5) |
Now we first set 65 at byte one, then set 66 at byte 5. With this second set, bytes 2 to 4 were filled with zeros. The echo will return: 65 0 0 0 66 | Now we first set 65 at byte one, then set 66 at byte 5. With this second set, bytes 2 to 4 were filled with zeros. The echo will return: 65 0 0 0 66 | ||
bset -t &test 1 just a test | bset -t &test 1 just a test |
Revision as of 16:57, 13 October 2006
The bset command is used to set a binary file.
bset [-t] <&binvar> <N> <asciivalue> [asciivalue ... asciivalue]
This sets the Nth byte of the binary file &binvar to the asciivalues. All asciivalues after are set to positions after the Nth byte. If you set a binary file that doesn't exist yet, the file will be created and zero filled to the Nth byte. If you set a binary file that already exists and is smaller then N bytes, it will be extended with zeros to the Nth byte.
The -t switch indicates that bset should treat the values as plain text and copy them directly into the binary file.
Examples
bset &test 1 65
Now &test is filled with 1 byte, and it containes asciivalue 65 wich is "A".
bset &test 5 65
In this case we only set one asciivalue at the 5th place, but the first 4 bytes are filled with zeros.
bset &test 1 65 bset &test 5 66 echo -a $bvar(&test,1,5)
Now we first set 65 at byte one, then set 66 at byte 5. With this second set, bytes 2 to 4 were filled with zeros. The echo will return: 65 0 0 0 66
bset -t &test 1 just a test echo -a $bvar(&test,1,$bvar(&test,0))
Using the -t switch the text will be converted to asciivalues and set to the binary file. The echo will return: 106 117 115 116 32 97 32 116 101 115 116. Which are the asciivalues of the text "just a test"