<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<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>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="constants+en">Previous</a>&nbsp;
<a href="continue+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Constant Declaration
</h1>
<div class="black"><font 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+en">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+en">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+en">Boolean</a>, <a href="type/integer+en">Integer</a>, <a href="type/long+en">Long</a>, <a href="type/float+en">Float</a> or <a href="../comp/gb/string+en">String</a>.
<p>
<div class="gray"><font 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+en">Variable Declaration</a>&nbsp;

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

