IIF

Is possible to make Visual Cobol code shorter similar to something like that ?

string ReturnValue = Expression == true ? TruePart : FalsePart;

Using this the code would be shorter by 4 lines.

Tags:

Parents
  • Ok, thank you.

    It's certainly possible to do it in two lines and it occurred to my mind but that's not what I'm looking for. I just like my code being simple but readable. That's why I very agree with you as for readability of code. But sometimes there're very simple parts of code with IF statement like following

    IF (l-anItem <> NULL)

        set x to 1

    ELSE

        set x to 0

    END-IF

    and in those cases such a syntax would be useful. Something like

    move IIF(l-anItem <> NULL, 1, 0) to x

    compute x = IIF(l-anItem <> NULL, 1, 0)

Reply
  • Ok, thank you.

    It's certainly possible to do it in two lines and it occurred to my mind but that's not what I'm looking for. I just like my code being simple but readable. That's why I very agree with you as for readability of code. But sometimes there're very simple parts of code with IF statement like following

    IF (l-anItem <> NULL)

        set x to 1

    ELSE

        set x to 0

    END-IF

    and in those cases such a syntax would be useful. Something like

    move IIF(l-anItem <> NULL, 1, 0) to x

    compute x = IIF(l-anItem <> NULL, 1, 0)

Children
No Data