Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Future consideration
Workspace IBM i
Categories Languages - RPG
Created by Guest
Created on Feb 27, 2024

Add OpCode for continuing to process "when" statements within Select group

sometimes it is necessary to need to process the remaining WHEN operands within a SELECT group.

if the "CONTSL" 'Continue Select' were used then the OTHERWISE should not be true.  (this up for discussion)

Currently we need to do if-then-else group.  this should make code cleaner and easier to read

example:

SELECT;
WHEN X = 1;  
  R = 1; 
  S = 'A';
  CONTSL;  //  -new "Continue Select" that would process the remaining "WHEN" 
WHEN ((Y = 2) AND (X < 10)); 
  R = 2; 
  S = 'B';
  OTHER; 
  R = 3; 
  S = 'C';
ENDSL;

Community, please comment with your thoughts.

Idea priority Low
  • Guest
    Reply
    |
    Jun 10, 2024
    IBM will use this Idea as input to planning, but no commitment is made or implied. This Idea will be updated in the future if IBM implements it. IBM will use votes and comments from others in the community to help prioritize this Idea.

    IBM will consider all the comments if this Idea is implemented. Please continue to add further comments to continue the discussion.

    -IBM Power Systems Development
  • Guest
    Reply
    |
    Mar 19, 2024

    I would prefer not having an extender to the SELECT opcode - opcodes should be concise and precise and not have some other meanings caused by a single letter. And the SELECT opcode has always been characterized by having ONLY ONE WHEN executed.

    The SELECT opcode has already been extended to allow a single value as parameter, to mimic the C construct of SWITCH-CASE. Adding further variations of execution to the SELECT structure will severely reduce the readability of the SELECT - IMHO...

    Why not simply copy the SWITCH-CASE (-ENDSW) construct from C for fall-through conditions? This would make it obvious that it's not a normal SELECT and have a different execution path. It could allow the same checks as SELECT (value or conditions) if needed, to make it easier to switch (no pun intended) between SELECT and SWITCH.


    We should avoid cramming too much logic into one single operation code - and the SELECT is already very complex / feature-full...

  • Guest
    Reply
    |
    Mar 4, 2024

    I like the previous March 4 comment about allowing both OTHER and FINAL-SL for my February 28 comment about adding an operation extender to SELECT.

    - Barbara Morris/IBM




  • Guest
    Reply
    |
    Mar 4, 2024

    I like Barbara's idea.

    Should we also allow a way to execute something if none of the WHEN conditions were true?

    Maybe allow OTHER when the operation extender is used:

    • Only execute the code in OTHER if none of the WHEN conditions were true, as usual.

    • Place the OTHER block before the FINAL-SL. The OTHER may or may not have a LEAVE-SL. If it doesn't, it continues on to the FINAL-SL.

    Or find some way to indicate in the FINAL-SL block if any WHENs (with no LEAVE-SL) were true? Maybe like an %other() BIF that returns TRUE if no WHENs were true ?


    I'd prefer allowing OTHER.

  • Guest
    Reply
    |
    Feb 29, 2024

    About the suggestion to use CASE if you want more CASE or WHEN to be checked, I think there would also need to be a way for a CASE block to stop further CASE or WHEN.


    So maybe it would be better to have an operation extender on the SELECT indicating that a new opcode such as LEAVE-SL is needed to stop processing the WHEN or OTHER statements. That way, instead of using CASE to indicate continue and WHEN to indicate do-not-continue, the RPG programmer can use LEAVE-SL to stop further checking of WHEN statements.


    So when processing reaches the end of an WHEN block, if there has not been a LEAVE-SL statement, it continues to do the comparison for subsequent WHEN statements.


    About the OTHER block, I think it makes most sense if it does the OTHER code if no WHEN comparison was true OR if it didn't hit a LEAVE-SL statement.


    Or, maybe a SELECT group with the operation extender would not have OTHER, but it would have a FINAL-SL opcode instead. So the FINAL-SL code would run unless it had seen a LEAVE-SL.


    Assuming the next opcode extender would be 'Q' (probably something else ...)

    -----------------------+----------+---------+--------+
    | x = 1 | x = 1 | x = 1 |
    | y = 2 | y = 0 | y = 0 |
    | z = 3 | z = 3 | z = 0 |
    -----------------------+----------+---------+--------+
    SELECT(Q); | start | start | start |
    WHEN x = 1; | true | true | true |
    in_when_1 = *on; | done | done | done |
    WHEN y = 2; | true | false | false |
    in_when_2 = *on; | done | - | - |
    leave-sl; | done | - | - |
    WHEN z = 3; | - | true | false |
    in_when_3 = *on; | - | done | - |
    final-sl; | - | final | final |
    in_final = *on; | - | done | done |
    endsl; | end | end | end |

    - Barbara Morris/IBM

  • Guest
    Reply
    |
    Feb 27, 2024

    Maybe it would be better to use a new opcode to replace WHEN for this?

    In C, IIRC, CASE is used. If a CASE condition is true, it executes the block then proceeds to evaluate the next CASE (unless there's a BREAK).

    So, maybe use CASE instead of WHEN when you want evaluations to continue, and use WHEN as usual when you want to get out of the SELECT:

    SELECT;

    CASE X = 1;

    R = 1;

    S = 'A';

    CASE ((Y = 2) AND (X < 10));

    R = 2;

    S = 'B';

    OTHER;

    R = 3;

    S = 'C';

    ENDSL;


    If a CASE or WHEN does evaluate to true, then OTHER is not executed.

    If a WHEN is executed, then leave the SELECT after execution, as usual, regardless if there are subsequent CASEs.


    Another example;

    select MenuOpt;

    case-in %range(1:3);

    Prep13();

    case-in %range(4:5);

    Prep45();

    when-is 1;

    DoOpt1();

    when-is 2;

    DoOpt2();

    when-is 3;

    DoOpt3();

    when-is 4;

    DoOpt4();

    when-is 5;

    DoOpt5();

    other;

    SndError('Invalid Menu Option Selected');

    endsl;


    If MenuOpt is 2, then Prep13() and DoOpt2() are executed.