| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
<html> |
| 13 |
<head> |
| 14 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 15 |
<meta http-equiv="Content-Language" content="en-us"> |
| 16 |
<title>enum2int</title> |
| 17 |
</head> |
| 18 |
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> |
| 19 |
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> |
| 20 |
<tr> |
| 21 |
<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> |
| 22 |
</tr> |
| 23 |
</table> |
| 24 |
<table border="0" align="right" cellpadding="0" cellspacing="0"> |
| 25 |
<tr> |
| 26 |
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> |
| 27 |
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> |
| 28 |
<td><a alt="previous" href="encvalue_unichar.html"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> |
| 29 |
<td><a alt="next" href="enumerated.html"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> |
| 30 |
</tr> |
| 31 |
</table> |
| 32 |
<p><br clear="all"> |
| 33 |
</p> |
| 34 |
<hr> |
| 35 |
<h1>enum2int</h1> |
| 36 |
<hr align="left" width="75%"/> |
| 37 |
<p>This function converts an <b><font face="Courier New">enumerated</font></b> value into an <b><font face="Courier New">integer</font></b> value associated to the enumerated value. |
| 38 |
<hr align="left" width="50%"/> |
| 39 |
<p>Related keyword:</p> |
| 40 |
<ul> |
| 41 |
<li><b><font face="Courier New" size="4" color="#003258"> <a href="integer.html">integer</a></font></b></li> |
| 42 |
<li><b><a href="enumerated.html"><font face="Courier New" size="4" color="#003258">enumerated</font></a></b></li> |
| 43 |
</ul> |
| 44 |
<hr align="left" width="50%"> |
| 45 |
<div align="center"> |
| 46 |
<center> |
| 47 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 48 |
<tr> |
| 49 |
<td width="100%"> |
| 50 |
<h3 align="center"> |
| 51 |
<font face="Courier New" color="#003258" size="5"><b>enum2int(in Enumerated_type inpar) return integer</b></font> |
| 52 |
</h3> |
| 53 |
|
| 54 |
</td> |
| 55 |
</tr> |
| 56 |
</table> |
| 57 |
</center> |
| 58 |
</div> |
| 59 |
<ul> |
| 60 |
<li> |
| 61 |
<p>The actual parameter passed to inpar always shall be a typed object.</p> |
| 62 |
</li> |
| 63 |
</ul> |
| 64 |
<hr align="left" width="25%"/> |
| 65 |
|
| 66 |
<p>Example:</p> |
| 67 |
<p> |
| 68 |
<font face="Courier New"> |
| 69 |
type enumerated MyFirstEnumType { <br/> |
| 70 |
Monday, Tuesday, Wednesday, Thursday, Friday<br/> |
| 71 |
};<br/> |
| 72 |
<br/> |
| 73 |
type enumerated MySecondEnumType {<br/> |
| 74 |
Saturday(-3), Sunday (0), Monday<br/> |
| 75 |
};<br/><br/> |
| 76 |
//within a dynamic language element:<br/> |
| 77 |
var MyFirstEnumType vl_FirstEnum := Monday;<br/> |
| 78 |
var MySecondEnumType vl_SecondEnum := Monday;<br/> |
| 79 |
<br/> |
| 80 |
enum2int(vl_FirstEnum) // returns 0<br/> |
| 81 |
enum2int(vl_SecondEnum) // returns 1<br/> |
| 82 |
<br/> |
| 83 |
vl_FirstEnum := Wednesday;<br/> |
| 84 |
vl_SecondEnum := Saturday;<br/> |
| 85 |
enum2int(vl_FirstEnum) // returns 2<br/> |
| 86 |
enum2int(vl_SecondEnum) // returns -3<br/> |
| 87 |
<br/> |
| 88 |
vl_FirstEnum := Friday;<br/> |
| 89 |
vl_SecondEnum := Sunday;<br/> |
| 90 |
enum2int(vl_FirstEnum) // returns 4<br/> |
| 91 |
enum2int(vl_SecondEnum) // returns 0<br/> |
| 92 |
</font> |
| 93 |
</p> |
| 94 |
|
| 95 |
<hr align="left" width="25%"/> |
| 96 |
</body> |
| 97 |
</html> |