To come out from if statement



Software AG's platform-independent programming language with full support for open-source and Internet applications

To come out from if statement

Postby diptisaini » Tue Apr 05, 2011 8:50 am

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?
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: To come out from if statement

Postby RGZbrog » Tue Apr 05, 2011 9:35 am

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
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time


Return to Natural

 


  • Related topics
    Replies
    Views
    Last post