Dec
Dec VariableToDecrease, [ OptionalAmount ]
 
Parameters:

    VariableToDecrease = The integer or floating point variable you wish to subtract one from.
    [ OptionalAmount ] = The amount to subtract from this variable. If not provided this defaults to 1
Returns: NONE
 

      The Dec command gives us an easier way to subtract one from integer or float variables.



FACTS:


      * Dec only works with Integer and Floating point variables.

      * Dec is shorthand for the expression Variable=Variable-1

      * The Dec does Not work with Arrays or Types.

      * Note: PlayBASIC also support various math short Operators, such as -- , and -= which perform the same operation as Dec, but can be used upon any data type.







Mini Tutorial:


Set a variable to a value, dec it and display the effect.

  
; create integer variable called Counter and assign it starting value of ten
  Counter=10
  
; Display the value of the counter variable
  Print Counter
  
; Subtract one from the counter variable.
  Dec Counter
  
; Display the value of the counter variable
  Print Counter
  
  
; Subtract five from the counter variable.
  Dec Counter, 5
  
; Display the value of the counter variable
  Print Counter
  
  
; Show Screen and wait for input to end
  Sync
  WaitKey
  
  


This example will output

  
  10
  9
  4
  



 
Related Info: Inc | Operators :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com