15 May 2017
Comments

Set off all indicators in RPG program

RPG INDICATORS are switches

Just like car indicators (or 'blinkers' as my American cousins call them) they can be switched *ON or *OFF in a program to indicate the state of a certain piece of logic. Using numeric indicators has been frowned upon for years, since the introduction of alphanumeric 'indicators' in programming code. After all, what makes more sense checking a value of *IN66 or checking a value of a field called ItemCodeValid?

Now saying that, older programs some times use numeric indicators extensively and this is just a neat way of turning off blocks of indicators:

// *IN is a standard RPGLE array for *IN(01) thru *in(99) - and it says turn off all from 01 to 99
%SubArr(*IN : 01 : 99) = *Off;

In older column based RPG (or RPG400) you could use the MOVEA (move array command) turn them all off

C MOVEA *ALL:‘0’ *in01

Or specify a smaller block of indicators:

C MOVEA ‘0000’ *in80

​would move *zeros to *in80, *in81, *in82, *in83

Lots of other techniques but I like the %subarr solution.

  • Nick Litten

    Nick Litten IBM i Software Developer

    Digital Dad, AS400 Anarchist, Software Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits.
     

    Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day.

    Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.