BitOnString and BitOrString (String functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 40: Line 40:


==See also==
==See also==
<table>
<tr>
<td>
<ul>
<ul>
<li><var>[[BitAndString (String function)|BitAndString]]</var>
<li><var>[[BitAndString (String function)|BitandString]]</var>
<li><var>[[BitOffString (String function)|BitOffString]]</var>
<li><var>[[BitOffString (String function)|BitOffString]]</var>
<li><var>[[BitOnString (String function)|BitOnString]]</var>
<li><var>[[BitXorString (String function)|BitXorString]]</var>
<li><var>[[BitXorString (String function)|BitXorString]]</var>
</ul>
</ul>
</td>
<td>
<ul>
<li><var>[[BitClearString, BitFlipString, and BitSetString (String functions)|BitClearString, BitFlipString, and BitSetString]]</var>
<li><var>[[BitValueString (String function)|BitValueString]]</var>
<li><var>[[BitCountString (String function)|BitCountString]]</var>
</ul>
</td>
[[Category:Bit manipulation methods]]
[[Category:Bit manipulation methods]]
{{Template:String:BitOrString footer}}
{{Template:String:BitOrString footer}}

Revision as of 01:06, 22 March 2013

Bitwise Or of strings (String class)

[Introduced in Sirius Mods 7.9]


These functions do a logical OR of the binary bits in two strings: that is, if the bits are "on" in either of the inputs, they are "on" in the output.

Syntax

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

%result = string:BitOrString( orBits, [Pad= c])

Syntax terms

%resultA string to receive the result of the logical OR operation on the bits of string and onBits (or string and orBits).
string A string.
onBits A string to be combined via bit-wise OR with the method object, string.
orBits A string to be combined via bit-wise OR with the method object, string.
Pad This name required parameter is the single-character value with which the shorter of the two input strings is to be extended. As many copies of 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 orBits is an easy way of ORing each byte in a string with a specific byte value (the Pad value).
  • BitOrString is most useful for working with binary data, for example binary data being sent or received with Janus Sockets.

Examples

The following example converts lowercase alphabetic characters to uppercase (because EBCDIC A-Z characters are equal to a-z characters plus X'40'):

%upper = %lower:bitOrString('', pad='40':x)

In the above code, if %lower were 'foobar', %upper would be set to 'FOOBAR'.

See also