INC
INC Variable
Variable 变量加1。
Variable 可以是赋值的任何类型数值变量。
等价于
Variable = Variable + 1
或者
Variable += 1
示例
Dim X As Integer
X = 7
INC X
PRINT X
DIM A AS New Float[3, 3]
Dim X, Y As Integer
X = 2
Y = 1
A[X, Y] = PI
INC A[X, Y]
PRINT A[X, Y]
一个更长的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
参见