From WikiChip
Editing mirc/identifiers/$bvar
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | {{mirc title|$bvar Identifier}}'''$bvar''' returns the contents of a binary variable. Default is returning the contents as decimal | + | {{mirc title|$bvar Identifier}}'''$bvar''' returns the contents of a binary variable. Default is returning the contents as decimal ASCII values in the range 0-255. |
− | |||
− | |||
− | |||
== Synopsis == | == Synopsis == | ||
<pre>$bvar(&binvar, [ N [ ,M] ] )</pre> | <pre>$bvar(&binvar, [ N [ ,M] ] )</pre> | ||
Line 11: | Line 8: | ||
* '''M''' - Optional length of the number of values to return. If there are not M bytes beginning at the Nth position, returns all the remaining bytes beginning at the Nth position. | * '''M''' - Optional length of the number of values to return. If there are not M bytes beginning at the Nth position, returns all the remaining bytes beginning at the Nth position. | ||
== Properties == | == Properties == | ||
− | * ''' | + | * '''text''' - Changes output from decimal ASCII numbers to text characters, truncated if $chr(0) encountered |
− | + | * '''word''' - Outputs decimal value of a 2-byte word, seeing bytes in little-endian byte order (low value first) | |
− | * ''' | + | * '''nword''' - Outputs decimal value of a 2-byte word, seeing bytes in big-endian byte order (high value first) |
− | * ''' | + | * '''long''' - Outputs decimal value of a 4-byte dword (unsigned long), seeing bytes in little-endian byte order (low value first) |
− | * ''' | + | * '''nlong''' - Outputs decimal value of a 4-byte dword (unsigned long), seeing bytes in big-endian byte order (high value first) |
− | * ''' | ||
− | |||
− | + | Note: $bvar(&var) used without N or M parameters returns the variable name if it exists, otherwise returns $null | |
+ | Note: word/nword/long/nlong return non-byte values ONLY when M is not used and N is a positive integer without a hyphen, and do not return a series of numbers from a lengthy variable. They return the value from the 2 or 4 bytes beginning at the Nth byte, and returns $null if there are not the needed 2 or 4 bytes to completely fill the word/long. | ||
== Example == | == Example == | ||
<source lang="mIRC">//bset &abc 1 12 34 56 78 | echo -a $iif($bvar(&abc),$v1 exists) $iif($bvar(&xyz),$v1 exists) / $bvar(&abc) / $bvar(&xyz) | <source lang="mIRC">//bset &abc 1 12 34 56 78 | echo -a $iif($bvar(&abc),$v1 exists) $iif($bvar(&xyz),$v1 exists) / $bvar(&abc) / $bvar(&xyz) | ||
Line 26: | Line 22: | ||
<source lang="mIRC"> | <source lang="mIRC"> | ||
− | //bset -ta &var 1 chlo $+ $chr( | + | //bset -ta &var 1 chlo $+ $chr(233) / $utfencode(chlo $+ $chr(233) ) | echo -a $bvar(&var,1-) // $bvar(&var,1-).text |
− | 99 104 108 111 233 32 47 32 99 104 108 111 195 | + | 99 104 108 111 233 32 47 32 99 104 108 111 195 169 // chloé / chloé |
− | //bset -t &var 1 chlo $+ $chr( | + | //bset -t &var 1 chlo $+ $chr(233) / $utfencode(chlo $+ $chr(233) ) | echo -a $bvar(&var,1-) // $bvar(&var,1-).text |
− | 99 104 108 111 195 169 32 47 32 99 104 108 111 195 131 194 | + | 99 104 108 111 195 169 32 47 32 99 104 108 111 195 131 194 169 // chloé / chloé |
− | //bset -t &var 1 chlo $+ $chr( | + | //bset -t &var 1 chlo $+ $chr(233) / $utfencode(chlo $+ $chr(233) ) | echo -a $bvar(&var,1-) // $bvar(&var,3-11).text |
− | 99 104 108 111 195 169 32 47 32 99 104 108 111 195 131 194 | + | 99 104 108 111 195 169 32 47 32 99 104 108 111 195 131 194 169 // loé / ch |
− | //bset -t &var 1 chlo $+ $chr( | + | //bset -t &var 1 chlo $+ $chr(233) / $utfencode(chlo $+ $chr(233) ) | echo -a $bvar(&var,1-) // $bvar(&var,3-11,5).text |
− | 99 104 108 111 195 169 32 47 32 99 104 108 111 195 131 194 | + | 99 104 108 111 195 169 32 47 32 99 104 108 111 195 131 194 169 // loé |
</source> | </source> | ||
Line 53: | Line 49: | ||
//bset &abc 1 $base(ef,16,10) $base(be,16,10) $base(ad,16,10) $base(de,16,10) | echo -a $base($bvar(&abc,1).long,10,16) $base($bvar(&abc,1).nlong,10,16) | //bset &abc 1 $base(ef,16,10) $base(be,16,10) $base(ad,16,10) $base(de,16,10) | echo -a $base($bvar(&abc,1).long,10,16) $base($bvar(&abc,1).nlong,10,16) | ||
</source> | </source> | ||
− | |||
== Compatibility == | == Compatibility == | ||
{{mIRC compatibility|5.3}} | {{mIRC compatibility|5.3}} |