From WikiChip
Editing mirc/commands/bset
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|/bset Command}} | {{mirc title|/bset Command}} | ||
− | The '''/bset''' command lets you assign specific ASCII values (or text) at a specific position. If the variable does not exist, a new binary variable will be created and zero- | + | The '''/bset''' command lets you assign specific ASCII values (or text) at a specific position. If the variable does not exist, a new binary variable will be created and zero-pad until <pos>. If <pos> exceeds the length of the variable, the variable will extend (by zero-padding the gap) to accommodate the new values. |
'''Note:''' Important fact to remember about binary variables is that they are not limited to the local scope of the alias but instead they remain set until processing is complete. Thus it's possible to use the same binary variable within multiple aliases if they call each other during the same script execution. | '''Note:''' Important fact to remember about binary variables is that they are not limited to the local scope of the alias but instead they remain set until processing is complete. Thus it's possible to use the same binary variable within multiple aliases if they call each other during the same script execution. | ||
== Synopsis == | == Synopsis == | ||
− | /bset | + | /bset -c <&bvar> <pos> <asciivalue> [asciivalue ... asciivalue] |
− | /bset - | + | /bset -tac <&bvar> <pos> <string> |
− | |||
== Switches == | == Switches == | ||
− | * '''-t''' - Indicates a string is to be written instead of | + | * '''-t''' - Indicates a string is to be written instead of literal ASCII values |
− | |||
* '''-c''' - Fills the binary variable with the string/ASCII values and truncates anything after it | * '''-c''' - Fills the binary variable with the string/ASCII values and truncates anything after it | ||
− | * '''- | + | * '''-a''' - Don't apply UTF-8 encoding to characters in the range 0-255, as long as the string parameter contains no characters > 255. |
== Parameters == | == Parameters == | ||
Line 19: | Line 17: | ||
* '''<pos>''' - The position to set the new ASCII values or the string, use -1 to append. The first byte of the string is pos 1. If <pos> is greater than the existing length of the binary variable, the string is zero-padded to fill undefined bytes between <pos> and the prior end of string. | * '''<pos>''' - The position to set the new ASCII values or the string, use -1 to append. The first byte of the string is pos 1. If <pos> is greater than the existing length of the binary variable, the string is zero-padded to fill undefined bytes between <pos> and the prior end of string. | ||
* '''<asciivalue>''' - ASCII 0-255 value to write. If values are in range 256 - 2^31-1, writes $and(value,255). If value >= 2^31, writes 255. | * '''<asciivalue>''' - ASCII 0-255 value to write. If values are in range 256 - 2^31-1, writes $and(value,255). If value >= 2^31, writes 255. | ||
− | * '''[asciivalue ... asciivalue]''' - | + | * '''[asciivalue ... asciivalue]''' - Succeeding ASCII values to be written |
− | * '''<string>''' - The string to be written. The | + | * '''<string>''' - The string to be written. The number of values is limited only by the 4150 character line length for the entire command including 'bset' |
== Example == | == Example == | ||
Line 64: | Line 62: | ||
; will print: 0 0 0 0 100 0 0 0 33 | ; will print: 0 0 0 0 100 0 0 0 33 | ||
echo -a $bvar(&var, 1-) | echo -a $bvar(&var, 1-) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}</syntaxhighlight> | }</syntaxhighlight> | ||
Line 94: | Line 76: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Binary variables are not limited to 4150 length. | + | Binary variables are not limited to 4150 length. It's more efficient to lengthen with /bcopy but bset can set long variables by repeatedly appending bytes. Max length of binary string can depend on your system resources. Fill a 7mb binary variable with all $chr(0)'s: |
+ | <syntaxhighlight lang="mIRC"> | ||
+ | /fill_with_zeroes 7654321 | ||
− | + | alias fill_with_zeroes { | |
− | + | if ($1 !isnum 1-) return | bset &var 1 0 | |
− | |||
− | |||
− | |||
− | |||
− | alias | ||
− | if ($1 !isnum 1-) return | bset &var 1 | ||
while ($1 > $bvar(&var,0)) { | while ($1 > $bvar(&var,0)) { | ||
bset &var -1 $str(0 $chr(32),$iif($calc($1 - $bvar(&var,0)) > 999,$v2,$v1)) | bset &var -1 $str(0 $chr(32),$iif($calc($1 - $bvar(&var,0)) > 999,$v2,$v1)) | ||
Line 109: | Line 87: | ||
} | } | ||
echo -a variable length is $bvar(&var,0) | echo -a variable length is $bvar(&var,0) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | </syntaxhighlight> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Compatibility == | == Compatibility == | ||
Line 167: | Line 100: | ||
* {{mIRC|/bwrite}} | * {{mIRC|/bwrite}} | ||
* {{mIRC|/breplace}} | * {{mIRC|/breplace}} | ||
− | |||
* {{mIRC|$bfind}} | * {{mIRC|$bfind}} | ||
* {{mIRC|/bunset}} | * {{mIRC|/bunset}} | ||
* {{mIRC|/btrunc}} | * {{mIRC|/btrunc}} | ||
− | |||
* [[List of commands - mIRC|List of commands]] | * [[List of commands - mIRC|List of commands]] | ||
* [[List of identifiers - mIRC|List of identifiers]] | * [[List of identifiers - mIRC|List of identifiers]] |