Please enable JavaScript to view this site.

 

Navigation: Macros > Macro Language > Operators

The inc / dec Operators (increment / decrement)

Scroll Prev Up Next More

The inc operator takes an integer variable and increases it by one. The dec operator takes an integer variable and decreases its value by one.

 

These operators are often used in a while loop.

// a very very inefficient method to calculate
// the number of days left in the current month
nDayLeftInMonth = 0
while MonthOf(Today() + nDayLeftInMonth) = MonthOf(Today()) 
   inc(nDayLeftInMonth)
endwhile
sRESULT = 'Days left = ' + IntToStr(nDayLeftInMonth)

Some important points to note about these 2 operators. They do not return a value that is assigned to another variable; they operate directly on the variable.

inc(231// incorrect !!!
inc(nDate + 12// incorrect !!!

Because of this, you can only use these operators on integer variables, not on literals or on expressions as is the case with most other operators.

 


Topic 135200, last updated on 18-Apr-2020