Difference between revisions of "$bvar"

From Scriptwiki
Jump to: navigation, search
m (added note to 1-)
m (moved from commands -> text and number identifiers)
 
(2 intermediate revisions by one other user not shown)
Line 20: Line 20:
 
  bset &test 1 65 66 67 68  
 
  bset &test 1 65 66 67 68  
 
  echo -a $bvar(&test,1,$bvar(&test,0)) returns ''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. Another way of doing this is ''echo -a $bvar(&test,1-)'', however this is undocumented.
This always returns all values in &test.
 
  
 
  bset &test 1 65 66 0 67 68  
 
  bset &test 1 65 66 0 67 68  
Line 28: Line 27:
  
 
[[Category:Binary Files]]
 
[[Category:Binary Files]]
[[Category:Commands]]
+
[[Category:Text and Number Identifiers]]

Latest revision as of 12:40, 11 April 2007

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

This always returns all values in &test. Another way of doing this is echo -a $bvar(&test,1-), however this is undocumented.

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.