[variable]+1 isn't longer a sum after GetItem "Label" [variable] - Forum

Forum Navigation
You need to log in to create posts and topics.

[variable]+1 isn't longer a sum after GetItem "Label" [variable]

Good afternoon,

I have a (very) simple webapp module that allows users to indicate each time they take a coffee.
When they reach a certain amount, they are offered to pay.

The variable of the number of coffees is stored with |SetItem "nCoffees" [nCoffees]| on Local storage.
With every click on the button the command |[nCoffees]+1| is executed and that works perfectly.
When the app is closed and reopened, the variable [nCoffees] is displayed correctly (retrieved with |GetItem "nCoffees" [nCoffees]| from Local Storage).
Now when the button is pressed and the command |[nCoffees]+1| is executed, the variable [nCoffees]1 indicates, the second time [nCoffees]11, [nCoffees]111, [nCoffees ]1111 … and further on.
So the sum is no longer made, but a number 1 is added with every click.
Does anyone have an idea where the error is?

grtz,

@guust it seems the variable is stored as a String instead of as a number. Try converting it to a number after GetItem using this command:

ToNumber "[nCoffees]" [nCoffees]

Regards.

Thanks for the amazing quick response.

I'll try it the first thing tomorrow morning.

Grtz,

@luishp

Thanks a lot!

I thought the problem must be there somewhere. But didn't know how to solve it.

It works, problem solved.

Have a nice day and n'joy the weekend.

Grtz,

 

luishp has reacted to this post.
luishp