END missing error



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

END missing error

Postby vinodj » Fri Feb 10, 2012 12:10 pm

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
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: END missing error

Postby BillyBoyo » Fri Feb 10, 2012 1:06 pm

Well, that is not an IBM mainframe Cobol is it? Wrong sort of place to ask that question then.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: END missing error

Postby NicC » Fri Feb 10, 2012 3:33 pm

Also, not using the code tags makes it difficult to read the structure of the 'program'.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: END missing error

Postby vinodj » Fri Feb 10, 2012 4:35 pm

Hello NicC,

I will take care of this next time.

Regards,
Vinod.
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: END missing error

Postby sinmani » Wed Apr 04, 2012 2:13 pm

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.
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time

Re: END missing error

Postby BillyBoyo » Wed Apr 04, 2012 2:29 pm

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?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: END missing error

Postby dick scherrer » Wed Apr 04, 2012 10:31 pm

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post