Modifying numerical variables?

SexigeOpe

Virgin
Joined
Sep 6, 2002
Posts
37
I've learned how to assign a new value to a variable, like: "From now on variable X is 5."
But how do you add/subtract from "current value"?
Back in the 80ies when I learned BASIC it was straightforward: If "X" was an integer and I wanted to add 4, then the command was "X=X+4", meaning "(new value of) X is (old value of) X, plus 4".
Do I really need to create a temporary variable, like
(Want to add 1 to X.)
~ y = X+1
~ X = y
 
Code:
VAR x = 5          // declare x to be 5

~ x += 1          // add one to x, it is now 6
~ x += 1          // add another one, x is now 7
~ x -= 1          // subtract, x is now 6 again

{x}          // display 6 in your text

If you're using Inky, make sure the commands to add one are on their own line, with nothing else on it. No other text or diverts or anything. Inky is a bit finicky with that.
 
Last place on the web that I expected a coding question to be asked 🤣... I bet the person who asked it is a big big fan of Lit 😜 and can't think of anything other than Lit....
 
Back
Top