Increment a variable
kingbp
Posts: 22
Hello Is thee anyone out there that can give me an example on how to increment a variable in PBASIc, I tried doing this Turns + 1, to increment a variable i called turns but it didn't work does anyone know how to increment a variable the proper way?
Comments
turns var byte
You can initialise it to be 0, 1 or any other value. Here, it starts at 1:
turns = 1
Here's how you increment:
turns = turns + 1
Here's how you decrement:
turns = turns - 1
[ "Turns++" is not PBasic]
The common way is either (but not in this case) turns++. This works in many languages, such as SPIN (I think), Java, C++ (I think) etc.
The next best thing is:
turns = turns + 1
turns = turns - 1
Bear in mind that Micros and other computery devices start counting from 0.
-John