<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - Constant Declaration
</title>
</head>
<body>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help%3Fen"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;&nbsp;
<a href="../lang%3Fen">Up</a>&nbsp;&nbsp;
<a href="constants%3Fen">Previous</a>&nbsp;&nbsp;
<a href="continue%3Fen">Next</a>&nbsp;&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Constant Declaration
</h1>
<div class="black"><font color="white" size="-2"><b>Syntax</b></font></div>
<pre class="syntax">{ <b>PUBLIC</b> | <b>PRIVATE</b> } <b>CONST</b> <u>Identifier</u> <b>AS</b> <u>Datatype</u> <b>=</b> <u>Constant value</u></pre><p>

<u><a href="const%3Fen">CONST</a></u> declares a class global constant.
<p>
This constant is accessible everywhere in the class it is declared.
<p>
If the <b><a href="public%3Fen">PUBLIC</a></b> keyword is specified, it is also accessible to the other
classes having a reference to an object of this class.
<p>
Constant datatype can be: <a href="type/boolean%3Fen">Boolean</a>, <a href="type/integer%3Fen">Integer</a>, <a href="type/long%3Fen">Long</a>, <a href="type/float%3Fen">Float</a> or <a href="../comp/gb/string%3Fen">String</a>.
<p>
<div class="gray"><font color="white" size="-2"><b>Example</b></font></div>
<pre class="example">PUBLIC CONST MAX_FILE AS Integer = 30

PRIVATE CONST DEBUG AS Boolean = TRUE

PRIVATE CONST MAGIC_HEADER AS String = &quot;# Gambas form file&quot;</pre>
<p>

<hr><b>See also</b><br>
<a href="vardecl%3Fen">Variable Declaration</a>&nbsp;&nbsp;

</div>
<hr>
</body>
</html>

