Short expressions – simple math expressions (+ = …)
: Is A=A+1 the same as A += 1 ?
The short answer is YES
If you are an old style RPG programmer, evolving into a modern RPG programmer you will frequently see this style of coding when looking at modern RPGLE code examples:
$variable += 1;
$variable -= 1;
$variable *= 2;
$variable /= 2;
This math notation simply means “take the right side and apply it to the left side of the value”
$variable += 1 could also be written at $variable = $variable + 1
Or we could negate a value by typing
$variable *= -1
I like it and have used this style for years.
But remember, don’t mix up up += with =+
$variable += 1will add one to the value $variable
$variable =+ 1will set the value of $variable to ‘+1’
“NOTE – dont mix up up += with =+”
that is enough reason for me to never use this style of coding
at least with $variable = $variable +1, there is no confusion.
Used Like in other Languages, there is no confusion, if you are not confused. Thats the best improvement ever.
If you still hold on old writing styles, you probably coding fixed format ?