Page 1 of 1

END missing error

PostPosted: Fri Feb 10, 2012 12:10 pm
by vinodj
Hello,

I wrote following block of code and I am getting 1 END (S) missing error. Could you help me out.

COMPUTE L = FUNCTION LENGTH(NAME)                     
  DISPLAY "L=  ", L.                                         
  INSPECT NAME(I: ) TALLYING A FOR ALL "."             
                                       
  DO UNSTR WHILE L >= I.                                     
       INSPECT NAME(I: ) TALLYING I FOR CHARACTERS     
             BEFORE '.'                                     
       IF A > 0                                             
         IF I NOT > L                                       
            ADD 1 TO I                                       
            UNSTRING NAME(J:I) DELIMITED BY             
                     "." INTO Q(K)                       
            ADD 1 TO K                                       
            COMPUTE J = I                                   
            SUBTRACT 1 FROM A                               
         END.                                               
       ELSE                                                 
          UNSTRING NAME(J:I) DELIMITED BY " " INTO Q(K)
          DISPLAY Q(K)                                       
          ADD 1 TO K                                         
       END.                                                 
  END UNSTR.                                                 
 
  DO UNSTR1 WHILE B <= 5.                                   
      INSPECT STRN REPLACING ALL 'X' BY B                   
      INSPECT TITLE TALLYING COUNT1 FOR ALL STRN         
      INSPECT TITLE REPLACING ALL STRN BY Q(B)           
      INSPECT STRN REPLACING ALL B BY 'X'                   
      INITIALIZE COUNT1                                     
      ADD 1 TO B                                       
  END UNSTR1.   
                                           
  MOVE SPACES TO TITLE1   
                               
  DO UNSTR2 VARY C FROM 1 BY 1 TO L.                       
   IF TITLE(C:1) = " "                                   
      CONTINUE                                             
   ELSE                                                     
      MOVE TITLE(C:1)TO TITLE1(D:1)                     
      ADD 1 TO D                                           
   END.                                                     
  END.

Code'd

Regards,
Vinod

Re: END missing error

PostPosted: Fri Feb 10, 2012 1:06 pm
by BillyBoyo
Well, that is not an IBM mainframe Cobol is it? Wrong sort of place to ask that question then.

Re: END missing error

PostPosted: Fri Feb 10, 2012 3:33 pm
by NicC
Also, not using the code tags makes it difficult to read the structure of the 'program'.

Re: END missing error

PostPosted: Fri Feb 10, 2012 4:35 pm
by vinodj
Hello NicC,

I will take care of this next time.

Regards,
Vinod.

Re: END missing error

PostPosted: Wed Apr 04, 2012 2:13 pm
by sinmani
A very bad way to write a program I must say.

Never use '.' in nested IF ELSE statement.

A '.' is a scopr terminator for IF , I think thats what casuing the problem for you.

Re: END missing error

PostPosted: Wed Apr 04, 2012 2:29 pm
by BillyBoyo
What do you make of the periods terminating the "DO" structure controls?

I'm not sure if the above is any Cobol, but it certainly isn't an IBM mainframe Cobol. Makes determining what is actually wrong with it somewhat tricky.

But, yes, with "end-" contstructs, avoid periods/fullstops and "NEXT SENTENCE". Use the explicit named-terminators and CONTINUE instead. What to do with just "END"? Who knows?

Re: END missing error

PostPosted: Wed Apr 04, 2012 10:31 pm
by dick scherrer
Hello,

The initial post has been "Code'd".

Either use the period as a terminator or END constructs - do not mix the bag and try to use both.