View Only

## ESP CLANG: Is it possible to create expressions based on even and odd numbered hours?

• #### 1.  ESP CLANG: Is it possible to create expressions based on even and odd numbered hours?

Posted 12-27-2017 03:29 PM

I am trying to create a CLANG expression based on hours of the day, in a similar way to days of the week.  For example, if you want a statement to be evaluated based on multiple days of the week, you could use something like this:

IF TODAY(MON WED FRID) THEN DO X.

I would like to do this for hours, like this:

IF ESPSHH(07 09 11 13...) THEN DO X

What would be even better is if it were possible to create an expression based on odd number hours or even number hours, like this:

IF ESPAHH <is an even number> THEN DO X

or

IF ESPAHH <is an odd number> THEN DO Y

I am trying to avoid having to use 24 repetitive lines, like:

IF ESPAHH EQ '01' THAN DO X

IF ESPAHH EQ '02' THEN DO Y

IF ESPAHH EQ '03' THEN DO X

'IF ESPAHH EQ '04' THEN DO Y

etc. etc. etc.

Any help would be much appreciated!

Thanks!

• #### 2.  Re: ESP CLANG: Is it possible to create expressions based on even and odd numbered hours? Best Answer

Posted 12-27-2017 04:16 PM

Hi Jonathan,

Hope following coding helps:

Note: for even number, after it's divided and then multiplied by, it will be the same; but for odd number, it will be different.

APPL TEST
INTEGER CHECK,CHECK1
CHECK = %ESPSHH
CHECK1= %CHECK/2
CHECK1= %CHECK1*2
IF %CHECK = %CHECK1 THEN ECHO "EVEN"
ELSE ECHO "ODD"

Lucy

• #### 3.  Re: ESP CLANG: Is it possible to create expressions based on even and odd numbered hours?

Posted 12-27-2017 04:41 PM

Lucy,

This worked perfectly!  I read through the section on ESP Procedures in the User Guide, but I couldn't quite determine how to do this kind of math.  This is a very nice example of it!  Thank you very much!!!!

<JC>