Bset

From Scriptwiki
Revision as of 15:50, 13 September 2006 by Vliedel (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

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.

bset -t &test 1 just a test

Using the -t switch the text will be converted to asciivalues and set to the binary file.