O'Reilly logo

APIs at Work, Second Edition by Ron Hawkins, Doug Pence, Bruce Vining

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monocasing Character Data Using the Convert Case API

The Convert Case API, QlgConvertCase, allows you to easily convert data from mixed case to either all-uppercase or all-lowercase. Now, you might be wondering at this point why you would want to use an API when RPG provides built-in functions such as %xlate for uppercasing, as shown in Figure 9.1.

Figure 9.1. RPG uppercasing of character data.
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++
dUpper            c                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dLower            c                   'abcdefghijklmnopqrstuvwxyz'
dText             s             20

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
 /free
  Text = %xlate( Lower :Upper :'Beckie');
 /end-free

After the %xlate built-in runs, the variable Text is set to “BECKIE,” ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required