User Tools

Site Tools


ugbasic:user:kw:dec
Translations of this page:


ugBASIC User Manual

DEC

SYNTAX

   DEC variable

PURPOSE

The DEC command is used to decrement (i.e. decrease) the value of a numeric variable by one. It is a quick and concise way to subtract 1 from the value contained in a variable. In place of variable, enter the name of the numeric variable you want to decrement.

The DEC command is actually a shorthand for the subtraction operation, as writing num=num-1. However, DEC is often preferred because of its more concise syntax and its specific decrement function. The DEC command can only be applied to numeric variables (integer).

EXAMPLE

  x = 43
  DEC x
  PRINT x: ' It prints "42"

ABBREVIATION

 Dc

AVAILABLE ON

SEE ALSO

INC

ANY PROBLEM?

If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please open an issue for this keyword on GitHub. Thank you!

POWERED BY