<!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 - INC
</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="in+en">Previous</a>&nbsp;
<a href="inherits+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
INC
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><b>INC</b> <u>Variable</u></pre><p>

Increments a variable.
<p>
<u>Variable</u> can be any target of an assignment, but must be numeric.
<p>
It is the exact equivalent of
<div class="box">
<tt><u>Variable</u> = <u>Variable</u> + 1</tt>
</div>
or
<p>
<div class="box">
<tt><u>Variable</u> += 1</tt>
</div>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">X = 7
INC X
PRINT X
<hr>8</pre>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">DIM A AS Float[3, 3]

X = 2
Y = 1

A[X, Y] = PI
INC A[X, Y]
PRINT A[X, Y]
<hr>4.14159265359</pre>
<p>
Here is a longer example in the terminal modus of <a href="../def/gambas+en">Gambas</a>:
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">STATIC PUBLIC SUB Main()

  DIM x AS Float
  DIM y AS Float
  DIM pos AS Integer
  DIM neg AS Integer
  DIM nul AS Integer

  pos = 0
  neg = 0
  nul = 0

  FOR x = 1 TO 100

    y = Rnd(-5, 5)
    SELECT CASE Sgn(y)
      CASE 0
        INC nul
        'the same as nul = nul + 1
      CASE 1
       INC pos
      CASE -1
       INC neg
    END SELECT

  NEXT

  PRINT nul,pos,neg

END</pre>
<p>
<hr><b>See also</b><br>
<a href="../cat/arith+en">Arithmetical Functions</a>&nbsp; <a href="assignop+en">Assignment Operators</a>&nbsp;

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

