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
// leave the program
as opposed to the rather old fashioned
// leave the program
So lets look at it. I really like this way because *IN?? could be called anything we like…
D PtrIndicators S * Inz(%Addr(*In)) D Indicators DS Based(PtrIndicators) D Exit 3 3N D Cancel 12 12N D Overflow 90 90N D Sfldspctl 91 91N D Sfldsp 92 92N D Sflend 93 93N D Sflclr 94 94N
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 35 keys specifically like this:
//define functions keys D FunctionKey s N dim(24) based(pFkeys) D pFkeys s * inz(%addr(*INKA))
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, 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.
‘device file does not contain an entry for screen size’
Using QSNRTVMOD to find the last displayed screen size
How can I learn modern RPG using ILE or Free Form?
AS400 Modernization starts with Modernizing RPG Applications
Dirty RPG programmers need to write Clean RPG Code
IBM i create JOBLOG from RPGLE /FREE – a QMHSNDPM code example
Write to joblog messages from RPGLE /FREE – easy code example using Qp0zLprintf
What is RPG OA?
RPG Example reading JSON using YAJL from IFS