Set off all RPG Indicators in a 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. In the IBM RPG language, it used to logically flick the switch of a numeric indicator 01-99 to “indicate” that something was happening.

rpg indicatorsFor example, we might switch on indicator 44 to say “invalid customer code” and then in every other place int he code we would say “if *IN44 is *ON then show this message, or print this warning or something”. Thats the end of this stating-the-obvious broadcast.

Using numeric indicators has been frowned upon for years, RPG has evolved and although it still fully supports using the old numeric style indicators, the introduction of alphanumeric ‘indicators’ in programming code makes much more sense. 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.

(0 votes) 0/10