Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: increment a variable  (Read 27364 times)

0 Members and 1 Guest are viewing this topic.

mstinnett

    Topic Starter


    Starter

    increment a variable
    « on: December 16, 2008, 11:08:58 AM »
    Is there a way to increment a variable in a batch file such as the way its done in C? (tick++ or ++tick)

    Thanks

    Dias de verano

    • Guest
    Re: increment a variable
    « Reply #1 on: December 16, 2008, 11:17:28 AM »
    Two alternatives:

    Method (1)

    Can be used in a loop or parenthetical expression, or elsewhere:

    Code: [Select]
    set /a variable+=1
    Method (2)
    Code: [Select]
    set /a variable=%variable% + 1
    In a loop or parenthetical expression you must use delayed expansion and

    Code: [Select]
    set /a variable=!variable!+1