UnderwareDESIGN

PlayBASIC => Beginners => Topic started by: ken tankerous on October 09, 2005, 11:22:34 AM

Title: Array element incrementing?
Post by: ken tankerous on October 09, 2005, 11:22:34 AM
How come this works:

PlayerScore(1) = PlayerScore(1) + 1

but this doesn't

Inc(PlayerScore(1))

According to the docs "Inc is shorthand for the expression Variable=Variable+1"

Thanks in advance
Ken
Title: Array element incrementing?
Post by: kevin on October 09, 2005, 11:28:10 AM
 way back in 2005, the  INC was only designed to work on variables.


EDIT Modern versions of PlayBASIC  have replaced the INC operator with the math short cuts operators such as ++, += etc These can be used on any data type during an assignment. See -> WIP (http://www.underwaredesign.com/forums/index.php?topic=3216.0)

 So you can use the ++ operator to replace INC,  

 EG..  So an expression like this

 PlayerScore(1) = PlayerScore(1) + 1

 becomes

 PlayerScore(1)++

 or you can also use += if you like.  

 PlayerScore(1)+=1   (add 1 to it )


 PlayerScore(1)+=20   (add 20 to it)