This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Decrementing an integer

Old posts that have not been replied to for several years.
Locked
Z
Zygomaticum

Post by Zygomaticum »

Hi there.

Is there a way to increment an integer value, or a string? (for example: to add 2 to 5 (result: 7 (doh))

set var 5
set varr [incr $var -2] doesn't work :sad:

greejtz, Zygo.

<font size=-1>[ This Message was edited by: Zygomaticum on 2002-03-03 15:22 ]</font>
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

To add 2 to a variable, you would either use:

Code: Select all

set variable 5
incr variable 2
Or:

Code: Select all

set variable 5
set variable [expr $variable + 2]
Z
Zygomaticum

Post by Zygomaticum »

ok, thx man
Locked