System.Enum

Posted by MBeynon on 16-Jan-2018 03:55

Hi,

I have a requirement to create a System.Enum and populate it with up to 12 members as I'm trying to populate Microsoft.Win32.TaskScheduler.MonthlyTrigger:MonthsOfYear which accepts a System.Enum.

The problem I'm having is I can't seem to find an example of how to get more than two items into my Enum, other than an example I found on this forum, using the OR of the OE EnumHelper and then calling the EnumHelper again with the output of the first!;

DEFINE VARIABLE rEnum AS System.Enum NO-UNDO.

rEnum = EnumHelper:Or(Microsoft.Win32.TaskScheduler.MonthsOfTheYear:January, Microsoft.Win32.TaskScheduler.MonthsOfTheYear:February).
        
 mt:MonthsOfYear = CAST(EnumHelper:Or(rEnum, Microsoft.Win32.TaskScheduler.MonthsOfTheYear:March), Microsoft.Win32.TaskScheduler.MonthsOfTheYear).

Is there a better way of doing this?

Many Thanks,

Mark.

All Replies

Posted by tpavlovic on 16-Jan-2018 04:24

ASSIGN rEnum = MonthsOfTheYear:AllMonths.

;)

If you're on 11.7 you can use OR.

ASSIGN rEnum =    MonthsOfTheYear:January
               OR MonthsOfTheYear:February
               OR MonthsOfTheYear:August
               OR MonthsOfTheYear:September
               OR MonthsOfTheYear:November
               .

Posted by MBeynon on 16-Jan-2018 04:58

Thanks for this :-)

I'm on OE102B however.

Sorry, I should have mention this in my post.

I've written a function that does what I want but it's a bit messy.

Mark.

Posted by Mike Fechner on 16-Jan-2018 05:25

If you need more than two, you need to stack the use of the EnumHelper:

rEnum = EnumHelper:Or(EnumHelper:Or(Microsoft.Win32.TaskScheduler.MonthsOfTheYear:January, Microsoft.Win32.TaskScheduler.MonthsOfTheYear:February), Microsoft.Win32.TaskScheduler.MonthsOfTheYear:March).

Posted by MBeynon on 16-Jan-2018 05:31

Yes that's whay I've done.

Thanks :-)

This thread is closed