• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Comparing Lists of Numbers to a Value

    September 20, 2002 Timothy Prickett Morgan

    Hey, Ted:

    It’s a shame you can’t do something like this in RPG:

    * if any of the fields > 25
    If       (field1 or field2 or field3) > 25 
             etc
    Endif
    
    * if all three fields > 25)
    If       (field1 and field2 and field3) > 25 
             etc
    Endif
    

    — David

    Who says you can’t, David? You just have to do it a different way. You know, cogitate external to the rectangular container constructed of corrugated paper.

    Many programming languages have minimum and maximum functions, which return one value from a list. OPNQRYF and Microsoft Excel come to mind.

    Below is source code for a module containing minimum and maximum functions for integers. To use them, pass a list of two to eight values to the function. Here’s an example of how to use them:

         D/copy prototypes,minmax
         D field1          s              5p 0
         D field2          s              5p 0
         D field3          s              5p 0
    
          * if field1 > 25 or field2 > 25 or field3 > 25
         C                   if        MaxInt(field1: field2: field3) > 25
          * at least one is greater, because the largest is greater
         C                   endif
          * if field1 > 25 and field2 > 25 and field3 > 25
         C                   if        MinInt(field1: field2: field3) > 25
          * all are greater, because the smallest is greater
         C                   endif
    

    I hope this helps.

    — Ted

    Prototype member:

         D MaxInt          pr            10i 0
         D  N1                           10i 0 value
         D  N2                           10i 0 value
         D  N3                           10i 0 value options(*nopass)
         D  N4                           10i 0 value options(*nopass)
         D  N5                           10i 0 value options(*nopass)
         D  N6                           10i 0 value options(*nopass)
         D  N7                           10i 0 value options(*nopass)
         D  N8                           10i 0 value options(*nopass)
    
         D MinInt          pr            10i 0
         D  N1                           10i 0 value
         D  N2                           10i 0 value
         D  N3                           10i 0 value options(*nopass)
         D  N4                           10i 0 value options(*nopass)
         D  N5                           10i 0 value options(*nopass)
         D  N6                           10i 0 value options(*nopass)
         D  N7                           10i 0 value options(*nopass)
         D  N8                           10i 0 value options(*nopass)
    

    Module member:

         H nomain
          /copy prototypes,minmax
    
         P MaxInt          b                   export
         D                 pi            10i 0
         D  N1                           10i 0 value
         D  N2                           10i 0 value
         D  N3                           10i 0 value options(*nopass)
         D  N4                           10i 0 value options(*nopass)
         D  N5                           10i 0 value options(*nopass)
         D  N6                           10i 0 value options(*nopass)
         D  N7                           10i 0 value options(*nopass)
         D  N8                           10i 0 value options(*nopass)
         D Value           s             10i 0
         D ParmCt          s             10i 0
         C                   eval      ParmCt = %parms
         C                   eval      Value = N1
         C                   if        N2 > Value
         C                   eval      Value = N2
         C                   endif
         C                   if        ParmCt >=3
         C                   if        N3 > Value
         C                   eval      Value = N3
         C                   endif
         C                   endif
         C                   if        ParmCt >=4
         C                   if        N4 > Value
         C                   eval      Value = N4
         C                   endif
         C                   endif
         C                   if        ParmCt >=5
         C                   if        N5 > Value
         C                   eval      Value = N5
         C                   endif
         C                   endif
         C                   if        ParmCt >=6
         C                   if        N6 > Value
         C                   eval      Value = N6
         C                   endif
         C                   endif
         C                   if        ParmCt >=7
         C                   if        N7 > Value
         C                   eval      Value = N7
         C                   endif
         C                   endif
         C                   if        ParmCt >=8
         C                   if        N8 > Value
         C                   eval      Value = N8
         C                   endif
         C                   endif
         C                   return    Value
         P                 e
    
         P MinInt          b                   export
         D                 pi            10i 0
         D  N1                           10i 0 value
         D  N2                           10i 0 value
         D  N3                           10i 0 value options(*nopass)
         D  N4                           10i 0 value options(*nopass)
         D  N5                           10i 0 value options(*nopass)
         D  N6                           10i 0 value options(*nopass)
         D  N7                           10i 0 value options(*nopass)
         D  N8                           10i 0 value options(*nopass)
         D Value           s             10i 0
         D ParmCt          s             10i 0
         C                   eval      ParmCt = %parms
         C                   eval      Value = N1
         C                   if        N2 < Value
         C                   eval      Value = N2
         C                   endif
         C                   if        ParmCt >=3
         C                   if        N3 < Value
         C                   eval      Value = N3
         C                   endif
         C                   endif
         C                   if        ParmCt >=4
         C                   if        N4 < Value
         C                   eval      Value = N4
         C                   endif
         C                   endif
         C                   if        ParmCt >=5
         C                   if        N5 < Value
         C                   eval      Value = N5
         C                   endif
         C                   endif
         C                   if        ParmCt >=6
         C                   if        N6 < Value
         C                   eval      Value = N6
         C                   endif
         C                   endif
         C                   if        ParmCt >=7
         C                   if        N7 < Value
         C                   eval      Value = N7
         C                   endif
         C                   endif
         C                   if        ParmCt >==8
         C                   if        N8 < Value
         C                   eval      Value = N8
         C                   endif
         C                   endif
         C                   return    Value
         P                 e
    

    Sponsored By
    ADVANCED SYSTEMS CONCEPTS

    SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:

    • Windows, Web or host user interfaces

    • Convert AS/400 data into PC file formats

    • E-mail or FTP query results, reports and spool files
    • Run-time prompted queries and reports for end users

    • IF-THEN-ELSE logic in queries and reports

    • Report, form and label formatting second to none

    • Easily convert date fields, character-to-numeric, numeric-to-character and other data manipulation

    • SORT or JOIN using a calculated field

    • Quick summarization of data with Tabling function

    • Run multiple SEQUEL requests as one with the SEQUEL Scripting function

    • OLAP Business Intelligence at a fraction of the cost of comparable solutions

    Take 6 minutes to view a SEQUEL ViewPoint ScreenCam movie to see how simple Windows-based AS/400 and iSeries data access can be! In just a few short minutes, you can find out ways to make your job easier and improve data access throughout your organization. Download the ViewPoint movie here .

    For more information or a FREE trial of SEQUEL, call 847/605-1311 or visit Advanced Systems Concepts.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 72 -- September 20, 2002

    Sponsored by
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Is It a Different ‘Hello World’ in OS/400 V5R1? Reader Feedback and Insights: Displaying Menu Options

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 72

This Issue Sponsored By

    Table of Contents

    • Reader Feedback and Insights: Thanks for the Tips
    • Comparing Lists of Numbers to a Value
    • JD Edwards Dates, Revisited

    Content archive

    • The Four Hundred
    • Four Hundred Stuff
    • Four Hundred Guru

    Recent Posts

    • Meet The Next Gen Of IBMers Helping To Build IBM i
    • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
    • Will Independent IBM i Clouds Survive PowerVS?
    • Now, IBM Is Jacking Up Hardware Maintenance Prices
    • IBM i PTF Guide, Volume 27, Number 24
    • Big Blue Raises IBM i License Transfer Fees, Other Prices
    • Keep The IBM i Youth Movement Going With More Training, Better Tools
    • Remain Begins Migrating DevOps Tools To VS Code
    • IBM Readies LTO-10 Tape Drives And Libraries
    • IBM i PTF Guide, Volume 27, Number 23

    Subscribe

    To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

    Pages

    • About Us
    • Contact
    • Contributors
    • Four Hundred Monitor
    • IBM i PTF Guide
    • Media Kit
    • Subscribe

    Search

    Copyright © 2025 IT Jungle