choose case ls_day case 'SATURDAY', 'SUNDAY' // do something end choose
Unfortunately, it's impossible to utilize the choose case construction to assign the comparison's result to a Boolean variable. To do that, we need to use a Boolean expression with OR:
lb_weekend = (ls_day = 'SATURDAY' or ls_day = 'SUNDAY')
That solution is not very elegant - a same variable is mentioned in code more than once. And if you need to compare to 30 values, not with just 2? Besides, we, database people, love normalization .
So, let me introduce the iin() function ("internal in"). It reports if the value, passed as the 1st argument, appears in the array, passed as the 2nd argument:
You can ask: how did I overload a global function in PowerScript? It's impossible! Not for me - I have a personal permission from the president of PowersoftSybaseSAP Appeon ! Ok, it's true that we cannot overload global functions in the Function Painter, but the source code can pass through a surgery. So, firstly create a normal, not-overloaded global function, save it and then re-open in with "Edit Source" and add the needed overloaded versions manually. After you add iin() to your application, explore its source code using the "Edit Source" mode.
HOW TO ADD THE FUNCTION TO THE APPLICATION
1. Save the file spy.pbl on your hard disk (in the folder where the PBLs are stored). The function is in that PBL. 2. Add it to your application's library list.
I have described how to overload global functions only for the sake of overloading existing global functions if a need arises. Don't create new global functions (the reasons are described here). If the old global function, being overloaded by you, would be created as an object's method (i.e. in the right way), you would not be forced to use the described trick to overload it.