HexToInteger (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
No edit summary
 
(35 intermediate revisions by 6 users not shown)
Line 1: Line 1:
This [[Intrinsic classes|intrinsic]] function returns the integer value of a hex-encoded string.    
{{Template:String:HexToInteger subtitle}}
                                                                                                     
<var>HexToInteger</var> is an [[Intrinsic classes|intrinsic]] function that returns the integer value of a hex-encoded string.
HexToInteger is available as of version 7.5 of the [[Sirius Mods]].                                 
 
===HexToInteger syntax===                                                                            
==Syntax==
  %num = string:hexToInteger([Signed=bool])                                                         
{{Template:String:HexToInteger syntax}}
Syntax Terms                                                                                         
===Syntax terms===
<dl>                                                                                                
<table class="syntaxTable">
<dt>%num                                                                                             
 
<dd>A numeric variable to receive the integer value of the method object string.  
<tr><th nowrap>%number</th>
<dt>string                                                                                          
<td>A numeric variable to receive the integer value of the method object <var class="term">string</var>.</td></tr>
<dd>A hex-encoded string value that contains an even number of characters.                          
 
<dt>Signed=bool                                                                                     
<tr><th>string</th>
<dd>This name-required argument (''''Signed'''') is a [[Boolean]] value that indicates whether the method object string is converted  
<td>A hex-encoded string value that contains an even number of characters.</td></tr>
to a signed integer. If ''''True'''', the method object is treated as if it were preceded by a negative sign,        
 
a two's complement conversion is performed, and the returned value is preceded by a negative sign.  
<tr><th><var>Signed</var></th>
                                                                                                     
<td>This is an optional, [[Methods#Named parameters|name required]], argument that is a <var>[[Boolean enumeration]]</var> value that indicates whether the method object string is converted to a signed integer.
Signed is an optional argument that defaults to ''''False'''', which                                 
<ul>
produces an unsigned conversion.                                                                    
<li><var>Signed</var> defaults to <var>False</var>, which produces an unsigned conversion.
                                                                                                     
<li>If <code>Signed=True</code>, the method object <var class="term">string</var> is treated as if it were preceded by a negative sign, a two's complement conversion is performed, and the returned value is preceded by a negative sign.</ul></td></tr>
</table>
 
==Exceptions==
This [[Intrinsic classes|intrinsic]] function can throw the following exceptions:
<dl>
<dt><var>[[InvalidHexData class|InvalidHexData]]</var>
<dd>If the method object string does not contain a properly encoded hexadecimal value.
The exception object indicates the position of the first invalid character
in the method object string, or it indicates a zero if the method object
string had an odd number of characters.
</dl>
</dl>


===See also===                                                                                       
==See also==
[[List of Intrinsic String Methods]]
{{Template:String:HexToInteger footer}}
 
[[Category:Intrinsic String methods|HexToInteger function]]
[[Category:Intrinsic methods]]
[[Category:System methods]]

Latest revision as of 21:25, 3 September 2015

Convert a hexadecimal string to an integer (String class)

[Introduced in Sirius Mods 7.5]

HexToInteger is an intrinsic function that returns the integer value of a hex-encoded string.

Syntax

%number = string:HexToInteger[( [Signed= boolean])] Throws InvalidHexData

Syntax terms

%number A numeric variable to receive the integer value of the method object string.
string A hex-encoded string value that contains an even number of characters.
Signed This is an optional, name required, argument that is a Boolean enumeration value that indicates whether the method object string is converted to a signed integer.
  • Signed defaults to False, which produces an unsigned conversion.
  • If Signed=True, the method object string is treated as if it were preceded by a negative sign, a two's complement conversion is performed, and the returned value is preceded by a negative sign.

Exceptions

This intrinsic function can throw the following exceptions:

InvalidHexData
If the method object string does not contain a properly encoded hexadecimal value. The exception object indicates the position of the first invalid character in the method object string, or it indicates a zero if the method object string had an odd number of characters.

See also