Page 1 of 1

To come out from if statement

PostPosted: Tue Apr 05, 2011 8:50 am
by diptisaini
Hi,

IF #SHRT-DESC = ' ' AND #ISS-LONG-NAME = ' '
DO
MOVE 'E072' TO #MSG-NO #ERRS-NO
<statement>
DOEND
ELSE
IF #SHRT-DESC = ' '
DO
MOVE 'E072' TO #MSG-NO #ERRS-NO
DOEND
IF #ISS-LONG-NAME = ' '
DO
MOVE 'E071' TO #MSG-NO #ERRS-NO
DOEND
DOEND

I just need to know what statement i need to code so that i can comeout from IF statement?

Re: To come out from if statement

PostPosted: Tue Apr 05, 2011 9:35 am
by RGZbrog
I wouldn't expect your code to Check or STOW - the DOs and DOENDs are mismatched. And it looks like an ELSE is missing. I indented the code to make it easier to read.
IF  #SHRT-DESC = ' ' AND #ISS-LONG-NAME = ' '
    DO
     MOVE 'both blank' TO #MSG-NO #ERRS-NO
     <statement>
    DOEND
  ELSE
    IF  #SHRT-DESC = ' '
        DO
         MOVE 'short blank' TO #MSG-NO #ERRS-NO
        DOEND
      ELSE    /* <-- missing?
        IF  #ISS-LONG-NAME = ' '
          DO
           MOVE 'long blank' TO #MSG-NO #ERRS-NO
          DOEND

DOEND   /* <--  mismatched

After one of the MOVE statements is executed, you automatically "come out" of the IF. No additional, explicit statement is needed.

In your example, all the THEN and ELSE blocks contain a single statement, so none of the DOs and DOENDs are necessary.
IF  #SHRT-DESC = ' ' AND #ISS-LONG-NAME = ' '
    MOVE 'both blank' TO #MSG-NO #ERRS-NO
  ELSE
    IF  #SHRT-DESC = ' '
        MOVE 'short blank' TO #MSG-NO #ERRS-NO
      ELSE
        IF  #ISS-LONG-NAME = ' '
            MOVE 'long blank' TO #MSG-NO #ERRS-NO