The New %HIVAL and %LOVAL BIFs

Bad Joke of the Month

My therapist told me that I’m unable to express my emotions.

I can’t say I’m surprised.

The New %HIVAL and %LOVAL BIFs

When I first saw the IBM announcement, I thought to myself “I’ve been using *HIVAL and *LOVAL for decades.”  Then I looked more carefully, they are BIFs starting with the % character!  It’s something new!  In fact, these BIFs work in conjunction with the enumeration support that IBM added to RPG last year.

Enumeration Support

Since these are related to the enumeration support feature that was added last year, if you aren’t already familiar with it, please check out my blog post from last December.  https://www.md-na.com/scotts-corner/enumeration-support/

New BIFs

The new %HIVAL and %LOVAL BIFs return the highest and lowest values, respectively, within an enumeration. For example:

dcl-enum category_codes qualified;

  deli         101;

  meat_frozen  110;

  meat_fresh   111;

  self_service 120;

  food_service 201;

end-enum;

 

if typedCat < %LOVAL(category_codes);

  errorMsg = ‘Category value too low!’;

else if typedCat > %HIVAL(category_codes);

  errorMsg = ‘Category value is too high!’;

endif;

More Information

For more information about these new features, including the PTFs needed to enable this support in IBM i 7.4 and 7.5, please see the following link in the RPG Café:
https://ibm.biz/rpgcafe_fall_2024_bifs_hival_loval

Scott Klement

Development and Solutions Architect 
Scott Klement is an IT professional with a passion for both programming and mentoring. He joined Midrange Dynamics at the beginning of October 2022. He formerly was the Director of Product Development and Support at Profound Logic and the IT Manager and Senior Programmer at Klement’s Sausage Co., Inc. Scott also serves on the Board of Directors of COMMON, where he represents the Education, Innovation, and Certification teams. He is an IBM Champion for Power Systems. 

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *