October 1


Simple short expressions in RPG

By NickLitten

October 1, 2021

plus, minus, RPG

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”

So – $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.

Try it!

But remember, don’t mix up up += with =+

  • $variable += 1 will add one to the value $variable
  • $variable =+ 1 will 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 ?

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips