Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add 1 to variable and store as another variable
#1
Hi,

I'm trying to add "1" to my variable, but I cant seem to get it working.

My Variables are:

Code:
Copy      Help
str rtime = 1
str rtime2 = (rtime + 1)

So when I try to output rtime2, it should be 2, but it still shows as 1.

Can anyone see what i'm doing wrong?
#2
you are using the wrong data type / operater combination.

you cannot simply add a string with an integer, so you must use the val function to return an integer, which in turn can be added to an integer.

if you want to use strings
str rtime = 1
str rtime2 = (val(rtime)+ 1)


if you just want to keep track of #'s

int rtime = 1
int rtime2 = rtime + 1
#3
Perfect!

Thanks, I completely forgot I was setting them as strings.

Thanks,
Paul.


Forum Jump:


Users browsing this thread: 1 Guest(s)