BitOnString and BitOrString (String functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(20 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Template:String:BitOrString subtitle}}
{{Template:String:BitOnString and BitOrString subtitle}}
 
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.  
<var>BitOrString</var> does a logical OR of the bits in two strings.  


==Syntax==
==Syntax==
{{Template:String:BitOnString syntax}}
{{Template:String:BitOrString syntax}}
{{Template:String:BitOrString syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%result</th><td>A string to receive the result of ORing together the bits in <var class="term">string</var> and <var class="term">orBits</var>.</td></tr>
<tr><th nowrap>%result</th><td>A string to receive the result of the logical OR operation on the bits of <var class="term">string</var> and <var class="term">onBits</var> (or <var class="term">string</var> and <var class="term">orBits</var>).</td></tr>
 
<tr><th>string</th>
<tr><th>string</th>
<td>One of the strings to be ORed.</td></tr>
<td>A string.</td></tr>
 
<tr><th>onBits</th>
<td>A string to be combined via bit-wise OR with the method object, <var class="term">string</var>.</td></tr>
 
<tr><th>orBits</th>
<tr><th>orBits</th>
<td>The other string to be ORed.</td></tr>
<td>A string to be combined via bit-wise OR with the method object, <var class="term">string</var>.</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 <var class="term">pad</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">pad</var> is <code>'00':x</code>.</td></tr>
<td>This [[Notation conventions for methods#Named parameters|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 <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.  
<p>
The default value of <var class="term">c</var> is <code>'00':x</code>.</p></td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li>Using a null <var class="term">string</var> for <var class="term">orBits</var> is an easy way of ORing each byte in a string with a specific byte value (the <var class="term">pad</var> value).
<li>Using a null string for <var class="term">orBits</var> is an easy way of ORing each byte in a <var class="term">string</var> with a specific byte value (the <var>Pad</var> value).
 
<li><var>BitOrString</var> is most useful for working with binary data, for example binary data being sent or received with <var class="product">[[Janus Sockets]]</var>.
<li><var>BitOrString</var> is most useful for working with binary data, for example binary data being sent or received with <var class="product">[[Janus Sockets]]</var>.
<li><var>BitOrString</var> was introduced in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> version 7.9.
</ul>
</ul>
==Examples==
==Examples==
<ol><li>The following example converts lower case alphabetic characters to upper case (because EBCDIC A-Z are equal to a-z plus X'40'):
The following example converts lowercase alphabetic characters to uppercase (because EBCDIC A-Z characters are equal to a-z characters plus X'40'):
<p class="pre">%upper = %lower:bitOrString('', pad='40':x)
<p class="pre">%upper = %lower:bitOrString(&#39;', pad='40':x)
</p>
</p>
In, the above code, if <code>%lower</code> were <code>'foobar'</code>, <code>%upper</code> would be set to <code class="output">'FOOBAR'</code>.
In the above code, if <code>%lower</code> were <code>'foobar'</code>, <code>%upper</code> would be set to <code class="output">'FOOBAR'</code>.
</ol>


==See also==
==See also==
<table>
<tr>
<td>
<ul>
<li><var>[[BitAndString (String function)|BitandString]]</var>
<li><var>[[BitOffString (String function)|BitOffString]]</var>
<li><var>[[BitXorString (String function)|BitXorString]]</var>
</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]]
{{Template:String:BitOrString footer}}
{{Template:String:BitOrString footer}}

Latest revision as of 20:25, 3 September 2015

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