Structured Assembler Macros: ELSEIF

The IF macro can be paired with an ELSEIF companion macro to build a simple case statement. In the code below, DAY is a one-byte character field containing a single digit representing a day of the week (1 = Sunday, 2 = Monday, …). We use the DAY field to build DAYO, a character version of the day. We combine this logic with an OR in the final condition to catch Saturday and Sunday.

        LOOP     EQU   *
                 IF (CLC,DAY,EQ,=C'2')
                    MVC  DAYO,=CL9'MONDAY'
                 ELSEIF (CLC,DAY,EQ,=C'3')
                    MVC  DAYO,=CL9'TUESDAY'
                 ELSEIF (CLC,DAY,EQ,=C'4')
                    MVC  DAYO,=CL9'WEDNESDAY'
                 ELSEIF (CLC,DAY,EQ,=C'5')
                    MVC  DAYO,=CL9'THURSDAY'
                 ELSEIF (CLC,DAY,EQ,=C'6')
                    MVC  DAYO,=CL9'FRIDAY'
                 ELSEIF (CLC,DAY,EQ,=C'1'),OR,(CLC,DAY,EQ,=C'7')
                    MVC  DAYO,=CL9'WEEKEND'
                 ENDIF
                 PUT   FILEOUT1,RECOUT         PRINT THE RECORD
                 GET   FILEIN1,RECIN           GET THE NEXT RECORD
                 B     LOOP                    GO BACK AND PROCESS

Leave a comment

Filed under IBM Mainframe Assembler

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s