$bvar

From Scriptwiki
Revision as of 23:48, 19 December 2006 by Cail (talk | contribs) (added note to 1-)

Jump to: navigation, search

The $bvar identifier is used to read a binary file

$bvar(&binvar,N,M)

This returns M ascii values starting at byte N from &binvar. If N+M -1 is larger then the size of &binvar, it will return ascii values starting at byte N to the last byte.

You can use N = 0 to return the size of &binvar.

Properties: text, word, nword, long, nlong

The word, nword, long, and nlong properties return values in host or network byte order.

Examples

bset &test 1 65 66 67 68
echo -a $bvar(&test,2,3) returns 66 67 68

This returns 3 ascii values starting at the second byte.

bset &test 1 65 66 67 68 
echo -a $bvar(&test,0) returns 4

This returns the size of &test, wich contains four ascii values.

bset &test 1 65 66 67 68 
echo -a $bvar(&test,1,$bvar(&test,0)) returns 65 66 67 68
;$bvar(&test,0) can also be replaced with 1- => echo -a $bvar(&test,1,1-)

This always returns all values in &test.

bset &test 1 65 66 0 67 68 
echo -a $bvar(&test,1,4).text returns AB

This returns the plain text of &test. Notice that it only returns text up to a zero value.