Set off all RPG Indicators in a program 

 April 15, 2018

By  NickLitten

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?

We can turn off everything in one simple Clear (or Reset if you set specific indicators *on/*off in *INZSR):

Clear *IN;

Now saying that, older programs some times use numeric indicators extensively and this is just a neat way of turning off blocks of indicators. SO, lets says we wanted to turn off all indicators higher than 20:

// *IN is a standard RPGLE array for *IN(01) thru *in(99) - and it says turn off all from 21 to 99
%SubArr(*IN : 21 : 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.


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad 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 remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

  • Minor note — this might not clear all (nor even most) indicators. Ever since the indicator data type was introduced, we’ve been able to create any number of indicators outside of the *IN data space. A new DS might be used to hold a block of program-specific indicators while the *IN indicators are reserved for “standard usage” in all programs.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    __CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

    Get In Touch

    I’m always looking for awesome input, feedback and critique!