Sync with 5.4.0
[deliverable/titan.core.git] / help / info / hexstring.html
CommitLineData
970ed795 1<!--
3abe9331 2 Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
3
4 All rights reserved. This program and the accompanying materials
5 are made available under the terms of the Eclipse Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/epl-v10.html
8 -->
9<html>
10<head>
11<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
12<meta http-equiv="Content-Language" content="en-us">
13<title>hexstring</title>
14</head>
15<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
16<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
17 <tr>
18 <td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td>
19 </tr>
20</table>
21<table border="0" align="right" cellpadding="0" cellspacing="0">
22 <tr>
23 <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
24 <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
25 <td><a alt="previous" href="hex2str.html"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
26 <td><a href="if.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
27 </tr>
28</table>
29<p><br clear="all">
30</p>
31<hr>
32<h1>hexstring</h1>
33<hr align="left" width="75%">
34<p>The keyword <b><font face="Courier New">hexstring</font></b> denotes a basic string type whose distinguished values are the ordered sequences of&nbsp; of hexadecimal digits, each corresponding
35to an ordered sequence of four bits.</p>
36<ul>
37 <li>hexadecimal string values are written between <a href="#double_quotation"> single quotes and followed by the capital letter H.</a> (' 'H).</li>
38 <li>A hexadecimal string may be specified by its integer value using a <a href="#conversion">conversion function</a>.</li>
39 <li>The <a href="#relation">relational operators</a> equality (==) and non-equality (!=) can be used to compare values of two hexadecimal strings</li>
40 <li>The <a href="#shift">shift operators</a> perform the shift left (&lt;&lt;) and shift right (&gt;&gt;) operations.</li>
41 <li>The <a href="#rotate">rotate operators</a> perform the rotate left (&lt;@) and rotate right (@&gt;) operations.</li>
42 <li>The <a href="#concatenation"> concatenation operator</a> (&amp;) performs a simple concatenation from left to right.</li>
43 <li>Bitwise operators (<a href="and4b.html">and4b</a>, <a href="not4b.html">not4b</a>, <a href="or4b.html">or4b</a>, <a href="xor4b.html"
44 target="_blank">xor4b</a>) are used to manipulate bits in the string.</li>
45 <li>A <a href="#array"> single octet</a> may be accessed using an array-like syntax. The leftmost octet has the index zero.</li>
46 <li>The hexadecimal string may be <a href="#vacuum">empty</a>.</li>
47 <li>The length of the hexadecimal string can be constrained using the keyword <a href="length.html"><b><font face="Courier New" color="#003258" size="4">length</font></b></a>.</li>
48 <li>Another way to limit the permitted values of an hexadecimal string is <a href="#list">to list them</a>.</li>
49 <li>Predefined functions operating on hexadecimal strings:</li>
50 <ul>
51 <li><a href="#bit2hex">hex2oct</a> converts a hexadecimal string value to an octet string.</li>
52 <li><a href="#str2int">hex2int</a> converts a hexadecimal string to the equivalent integer.</li>
53 <li><a href="#str2oct">hex2bit</a> converts a hexadecimal string to a binary string.</li>
54 <li><a href="#bit2str">hex2str</a> displays a hexadecimal string as a character string.</li>
55 <li><a href="#lengthof">lengthof</a> returns an integer value indicating the number of octets in a string.</li>
56 </ul>
57</ul>
58<p>Related keyword:</p>
59<ul>
60 <li><a href="bit2hex.html"><b><font face="Courier New" color="#003258" size="4">bit2hex</font></b></a></li>
61 <li><a href="hex2bit.html"><b><font face="Courier New" color="#003258" size="4">hex2bit</font></b></a></li>
62 <li><a href="hex2int.html"><b><font face="Courier New" color="#003258" size="4">hex2int</font></b></a></li>
63 <li><a href="hex2oct.html"><b><font face="Courier New" color="#003258" size="4">hex2oct</font></b></a></li>
64 <li><a href="hex2str.html"><b><font face="Courier New" color="#003258" size="4">hex2str</font></b></a></li>
65 <li><a href="int2hex.html"><b><font face="Courier New" color="#003258" size="4">int2hex</font></b></a></li>
66 <li><a href="length.html"><b><font face="Courier New" color="#003258" size="4">length</font></b></a></li>
67 <li><a href="lengthof.html"><b><font face="Courier New" color="#003258" size="4">lengthof</font></b></a></li>
68 <li><a href="oct2hex.html"><b><font face="Courier New" color="#003258" size="4">oct2hex</font></b></a></li>
69 <li><a href="str2hex.html"><b><font face="Courier New" color="#003258" size="4">str2hex</font></b></a></li>
70 <li><a href="substr.html"><b><font face="Courier New" color="#003258" size="4">substr</font></b></a></li>
71 <li><a href="and4b.html"><b><font face="Courier New" color="#003258" size="4">and4bit</font></b></a></li>
72 <li><a href="not4b.html"><b><font face="Courier New" color="#003258" size="4">not4bit</font></b></a></li>
73 <li><a href="or4b.html"><b><font face="Courier New" color="#003258" size="4">or4bit</font></b></a></li>
74 <li><a href="xor4b.html"><b><font face="Courier New" color="#003258" size="4">xor4bit</font></b></a></li>
75</ul>
76<hr align="left" width="50%">
77<div align="center">
78<center>
79<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
80 <tr>
81 <td width="100%">
82 <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>hexstring</b></font></h3>
83 </td>
84 </tr>
85</table>
86</center>
87</div>
88<hr align="left" width="50%">
89<p><a name="double_quotation">Example 1</a>:
90<p><font face="Courier New">const hexstring c_elch := 'C'H;<br>
91</font>
92<p>The constant called c_elch contains the hexadecimal string C.</p>
93<hr align="left" width="50%">
94<p><a name="conversion">Example 2</a>:
95<p><font face="Courier New">const hexstring c_entiere := int2hex (64,3);<br>
96</font>
97<p>The constant c_entiere will contain the hexadecimal string 040 because the converted integer number (64 -&gt; 40) must be coded on 3 hexadecimal digits and therefore padded with a leading zero.</p>
98<hr align="left" width="50%">
99<p><a name="relation">Example 3</a>:
100<p><font face="Courier New">const boolean c_undanbedes := ( c_entiere == c_elch );<br>
101</font>
102<p>The constant c_undanbedes will have the value false, because two hexadecimal strings are not equal. The parentheses are optional.</p>
103<hr align="left" width="50%">
104<p><a name="concatenation">Example 4</a>:
105<p><font face="Courier New">const hexstring c_samman := c_entiere &amp; c_elch;<br>
106</font>
107<p>The constant c_samman will contain the hexadecimal string 040C&nbsp;</p>
108<hr align="left" width="50%">
109<p><a name="array">Example 5</a>:
110<p><font face="Courier New">const hexstring c_lakomec := c_entiere[1];<br>
111</font>
112<p>The constant called c_lakomec will contain the hexadecimal string 4.</p>
113<hr align="left" width="50%">
114<p><a name="vacuum">Example 6</a>:
115<p><font face="Courier New">const hexstring c_tomt := ''H;<br>
116</font>
117<p>The constant called c_tomt will be an empty string.</p>
118<hr align="left" width="50%">
119<p><a name="bit2hex">Example 7a</a>:
120<p><font face="Courier New">const octetstring c_kaprifol := hex2oct ('7AA'H);</font><br>
121<p>The constant called c_kaprifol will contain the octet string 07AA. The resulting octet string contains 0 as leftmost hex digit followed by the same sequence of hex digits as in the hexadecimal
122string because the number of the hexadecimal digits is odd.</p>
123<hr align="left" width="50%">
124<p><a name="str2int">Example 7b</a>:
125<p><font face="Courier New">const integer c_gondol := hex2int ('555'H);<br>
126</font>
127<p>The constant called c_gondol will have the integer value 1365. The result will be always positive.</p>
128<hr align="left" width="50%">
129<p><a name="str2oct">Example 7c</a>:
130<p><font face="Courier New">const bitstring c_perrongen := hex2bit ('A7'H);<br>
131</font>
132<p>The constant called c_perrongen will contain the bit string 10100111.</p>
133<hr align="left" width="50%">
134<p><a name="bit2str">Example 7d</a>:
135<p><font face="Courier New">const charstring c_snaella := hex2str ('BBC0530A0'H);<br>
136</font>
137<p>The constant called c_snaella will contain the string BBC0530A0 because the resulting character string has the same length as the hexadecimal string and contains only the characters '0' .. 'F'.</p>
138<hr align="left" width="50%">
139<p><a name="lengthof">Example 7e</a>:
140<p><font face="Courier New">const integer c_skynda := lengthof ('BBC0530A0'H);<br>
141</font>
142<p>The constant called c_skynda will have the value 9 corresponding to the number of octets in the string.</p>
143<hr align="left" width="50%">
144<p><a name="list">Example 8</a>:
145<p><font face="Courier New">var hexstring c_mot ('010'H,'77'H,'A55CC'H );<br>
146</font>
147<p>The variable called c_mot may hold the hexadecimal strings 010, 77 and A55CC only.</p>
148<hr align="left" width="50%">
149<p><a name="rotate">Example 9</a>:&nbsp;</p>
150<p><font face="Courier New">const hexstring c_koerhinta := '12345'H @&gt; 2;<br>
151</font>
152<p>The constant called c_koerhinta will hold the value '45123'H (the left operand rotated by two hexadecimal digits).&nbsp;</p>
153<hr align="left" width="50%">
154<p><a name="shift">Example 10</a>:</p>
155<p><font face="Courier New">const hexstring c_wet := '12345'H &gt;&gt; 2;&nbsp;<br>
156</font>
157<p>The constant called c_wet will hold the value '00123'H (the left operand shifted by two hexadecimal digits).</p>
158<hr align="left" width="25%">
159<hr align="left" width="25%">
160<p align="left"><a HREF="BNF.html#hexstringkeyword">BNF definition</a> of <font face="Courier New">hexstring</font><br>
161<a HREF="BNF.html#hexstringvalue">BNF definition</a> of hexstring value</p>
162</body>
163</html>
This page took 0.03129 seconds and 5 git commands to generate.