How to use named indicators in RPG 

 June 30, 2017

By  NickLitten

When is an RPG indicator more than just a number? We can use a named data structure to overlay over the top of all the indicators used in the program. Using this technique, we can define a sensible name for the each of the memory spaces associated with the indicators.

For example — when the user presses F3 to exit we can do this in the program code as

If Exit;
// leave the program

as opposed to the rather old fashioned

If *in03;
// leave the program

So lets look at it. I really like this way because *IN?? could be called anything we like…

dcl-s PtrIndicators pointer Inz(%Addr(*In));

dcl-ds *n based(PtrIndicators)
  Exit ind pos(3);
  Cancel ind pos(12);
  somethingforindicator50 ind pos(50);
  Overflow ind pos(90);
  Sfldspctl ind pos(91);
  Sfldsp ind pos(92);
  Sflend ind pos(93);
  Sflclr ind pos(94);

In this example, if Indicator03 is the Exit Key then we can call it ‘EXIT’ and in our code we can say

If EXIT ‘do-something’

Which is much cleaner than ‘If *IN03 ‘do-something’ right?

When is a Function Key more than a Command Key?

Another technique I like, specifically when referencing the Functions keys (or command keys as they used to be called is to reference the first 24 PF keys specifically. Command Keys aka Program Function Keys can be referenced like this:

//define functions keys
dcl-s ptr_FunctionKey pointer inz(%addr(*INKA));
dcl-s FunctionKey ind dim(24) based(ptr_FunctionKey);

Then you can say

If FunctionKey(01) Do-Something

I like both techniques, so take your pick!

Fun with Indicators 101.

Seton LR 🙂


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:

{"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!