Difference between revisions of "$bvar"
From Scriptwiki
m |
m (moved from commands -> text and number identifiers) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
The $bvar identifier is used to read a [[:Category:Binary Files|binary file]] | The $bvar identifier is used to read a [[:Category:Binary Files|binary file]] | ||
<nowiki>$bvar(&binvar,N,M)</nowiki> | <nowiki>$bvar(&binvar,N,M)</nowiki> | ||
− | This returns ''M'' [[$asc|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. | + | This returns ''M'' [[$asc|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. | You can use ''N'' = 0 to return the size of &binvar. | ||
Properties: text, word, nword, long, nlong | Properties: text, word, nword, long, nlong | ||
+ | |||
+ | The word, nword, long, and nlong properties return values in host or network byte order. | ||
== Examples == | == Examples == | ||
Line 18: | 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'' | ||
− | This always returns all values in &test. | + | 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 | bset &test 1 65 66 0 67 68 | ||
echo -a $bvar(&test,1,4).text returns ''AB'' | 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. | This returns the plain text of &test. Notice that it only returns text up to a zero value. | ||
+ | |||
+ | [[Category:Binary Files]] | ||
+ | [[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.