BitOnString and BitOrString (String functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
{{Template:String:BitOrString subtitle}}
{{Template:String:BitOnString and BitOrString subtitle}}
 
These functions do a logical OR of the bits in two strings, that is, output bits are "on" if they are "on" in either of the inputs.  
<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===

Revision as of 20:48, 29 September 2012

Bitwise Or of strings (String class)

[Introduced in Sirius Mods 7.9]

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

Syntax

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

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

Syntax terms

%resultA string to receive the result of combinining the bits in string and orBits as a result of the logical OR operation.
string One of the strings in the logical OR operation.
orBits The other string in the logical OR operation.
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 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