I have the following code and as can be seen that in both the cases I'm using Section = A. But, is there a way to check both 1&2 in "When" so that to avoid more lines of code?
Evaluate INTERFACE
When "1"
SECTION = "A";
Break;
When "2"
SECTION = "A";
Break;
Any help is highly appreciated and please remember I'm still, learning. Thanks! :)
first of all: Your code does not really look like Java, C or Cpp, and it has nothing to do with OOP, so correct the tags.
To the question:
After a quick search for Evaluate-When
it seems like COBOL (see IBM) with the same attributes as the well-known switch-case
.
In switch-case
you can not really have OR
statements, but you can assign multiple values to the same block by not using the break
:
char c = 'a';
switch(c){
case 'a':
case 'A':
fooA(); //'a' AND 'A' will land here
break;
case 'b':
fooSmallB(); //only 'b' lands here
case 'B':
fooB(); //'b' AND 'B' lands here
break;
default:
fooDef(); //Everything that does not hit any case lands here
}
This simulates an OR-statement. And is not possible.
EDIT: I see now, the language is peoplecode. Never heard of that before, but documentation shows: Evaluate-When is not much different than Switch-Case
Nevertheless: There is nearly always a better possibilities than switch-case
, see 1st comment from Michael here.