BitOnString (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 11: Line 11:
<td>The string to set bits in.</td></tr>
<td>The string to set bits in.</td></tr>
<tr><th>onBits</th>
<tr><th>onBits</th>
<td>The bits to set.</td></tr>
<td>A string that specifies the bits to set.</td></tr>
<tr><th><var>Pad</var></th>
<tr><th><var>Pad</var></th>
<td>A single character that indicates the character with which the shorter of the two input strings is to be extended. As many copies of pad character <var class="term">c</var> are used as is required to make the shorter string as long as the longer. If both strings are of equal length, no padding is required. The default value of <var class="term">c</var> is <code>'00':x</code>.</td></tr>
<td>A single character that indicates the character with which the shorter of the two input strings is to be extended. As many copies of pad character <var class="term">c</var> are used as is required to make the shorter string as long as the longer. If both strings are of equal length, no padding is required. The default value of <var class="term">c</var> is <code>'00':x</code>.</td></tr>

Revision as of 22:02, 5 June 2012

Set bits in one string from another (String class) [introduced in Sirius Mods 7.9]


BitOnString sets bits in one string as indicated by another.

Syntax

%result = string:BitOnString( onBits, [Pad= c])

Syntax terms

%resultA string to receive the result of setting the bits in onBits for the method object, string.
string The string to set bits in.
onBits A string that specifies the bits to set.
Pad A single character that indicates the character with which the shorter of the two input strings is to be extended. As many copies of pad character c are used as is required to make the shorter string as long as the longer. If both strings are of equal length, no padding is required. The default value of c is '00':x.

Usage notes

  • Using a null string for onBits is an easy way of turning on a specific set of bits for each byte in a string (the Pad value).
  • BitOnString is most useful for working with binary data, for example binary data being sent or received with Janus Sockets.

See also