lang • inc

INC

INC Variable

Increments a variable.

Variable can be any target of an assignment, but must be numeric.

It is the exact equivalent of

Variable = Variable + 1

or

Variable += 1

Examples

X = 7
Inc X
Print X
8
Dim A As Float[3, 3]

X = 2
Y = 1

A[X, Y] = Pi
Inc A[X, Y]
Print A[X, Y]
4.14159265359

Here is a longer example in the terminal modus of Gambas:

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

See also