Menu

Cannot compile RM/COBOL program. Unexpected end of file

2024-01-18
2024-01-18
  • Michael Smith

    Michael Smith - 2024-01-18

    Output of cobc --info

    cobc (GnuCOBOL) 4.0.0
    Copyright (C) 2022 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
    Built     Jan 18 2024 00:28:12
    Packaged  Jan 18 2024 06:22:34 UTC
    C version "9.4.0"
    
    build information
    build environment        : x86_64-pc-linux-gnu
    CC                       : gcc
    C version                : "9.4.0"
    CPPFLAGS                 :
    CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                               -Wall -Wwrite-strings -Wmissing-prototypes
                               -Wno-format-y2k
    LD                       : /usr/bin/ld -m elf_x86_64
    LDFLAGS                  :  -Wl,-z,relro,-z,now,-O1
    
    GnuCOBOL information
    COB_CC                   : gcc
    COB_CFLAGS               : -pipe -I/usr/local/include -Wno-unused
                               -fsigned-char -Wno-pointer-sign
    COB_DEBUG_FLAGS          : -ggdb3 -fasynchronous-unwind-tables
    COB_LDFLAGS              :
    COB_LIBS                 : -L/usr/local/lib -lcob
    COB_CONFIG_DIR           : /usr/local/share/gnucobol/config
    COB_SCHEMA_DIR           : /usr/local/share/gnucobol/schema
    COB_COPY_DIR             : /usr/local/share/gnucobol/copy
    COB_MSG_FORMAT           : GCC
    COB_OBJECT_EXT           : o
    COB_MODULE_EXT           : so
    COB_EXE_EXT              :
    64bit-mode               : yes
    BINARY-C-LONG            : 8 bytes
    endianness               : little-endian
    native character set     : ASCII
    extended screen I/O      : ncursesw
    variable file format     : 0
    sequential file handler  : built-in
    indexed file handler     : BDB
    mathematical library     : GMP
    XML library              : disabled
    JSON library             : not found
    

    I am trying to compile the following program which I will include in its entirety for the sake of it.

    I try to compile with:

    cobc -W -v -x -I . -I COPYBOOK/ -std=rm-strict -findirect-redefines FXSHHIST.CBL2

    You may notice some odd code, I am learning how to write COBOL and I wrote in a lot of END-IF and END-ACCEPT to appease every single possible error from the -W flag.

    Line endings should be simple \n, and there are absolutely NO tabs. All lines of code should be in fixed format, terminating before column 72.

    This snippet of code does correctly compile on RM/COBOL 12.17

           IDENTIFICATION DIVISION.
           PROGRAM-ID. FXSHHIST.
          *DATE-COMPILED.
           ENVIRONMENT DIVISION.
           CONFIGURATION SECTION.
    
           COPY JDSECURE.
          ******************************************************************
          *       C H A N G E   &   E N H A N C E M E NT   L O G           *
          ******************************************************************
          * prompt for Loc, WO, Seg
          * Run through each SHHIST - USED DEBUG to fix a field
          * this will rewrite it for you
          ******************************************************************
    
           INPUT-OUTPUT SECTION.
           FILE-CONTROL.
               SELECT SHHIST
                   ASSIGN TO RANDOM "HIST"
                   ORGANIZATION IS INDEXED
                   ACCESS MODE IS DYNAMIC
                   RECORD KEY IS SH-KEY
                   ALTERNATE RECORD KEY IS SH-CUST-ALPHA WITH DUPLICATES
                   FILE STATUS IS STATUS-KEY.
          *
           DATA DIVISION.
           FILE SECTION.
           COPY FSHHIST.
           WORKING-STORAGE SECTION.
           COPY W1FKEY.
           01  WS-CTR    PIC 9(3).
           01  UPD-SW    PIC X.
           01  SAVE-SERNO       PIC X(20).
           01  SAVE-WO          PIC 9(9).
           01  SAVE-SEG         PIC 9(2).
           01  ALL-OK-SW        PIC X.
               88 ALL-OK-VALID      VALUE "Y" "N" "Q".
               88 ALL-OK-YES        VALUE "Y".
               88 ALL-OK-QUIT       VALUE "Q".
           01  DONE-SW          PIC X.
               88 DONE                VALUE "Y".
           01  DUMMY            PIC X.
           01  BLANK-LINE       PIC X(79) VALUE SPACES.
           01  DISP-CNT         PIC ZZZZZ9.
           01  FIELD-LETTER     PIC X.
           01  FIELD-CONFIRM    PIC X.
           01  CLEAR-SCREEN     PIC XXXX VALUE X"1B5B324A".
           01  WS-MAKE          PIC X(5).
    
          * USER I/O VARIABLES
           01  IO-YESNO-POS-X   PIC 99.
           01  IO-YESNO-POS-Y   PIC 99.
    
           01  IO-YESNO         PIC X.
               88 IO-YES           VALUE "Y".
               88 IO-NO            VALUE "N".
           01  IO-YESNO-POS-X2  PIC 99.
    
    
    
          * PRINT VARIABLES
           01  LINE-NUMBER      PIC 99.
    
           COPY W1USE.
          /
           PROCEDURE DIVISION.
           DECLARATIVES.
           SHHIST-STATUS SECTION.
                USE AFTER STANDARD EXCEPTION PROCEDURE ON SHHIST.
           USE-SHHIST.
                MOVE "I" TO FILE-TYPE.
                MOVE "SHHIST  " TO STAT-FILE.
                PERFORM USE-PERFORM THRU USE-EXIT.
                GO TO USE-END.
          *COPY P1USE.
          ******************************************************************
           MAIN-CONTROL SECTION.
          *
           0000-BEGIN-PROGRAM.
               MOVE "ERROR: " TO MSG-TYPE.
               MOVE "FXSHHIST" TO PROGRAM-NAME.
               PERFORM 1100-DRAW-TITLE.
    
               OPEN I-O SHHIST
    
               MOVE ZEROS TO STATUS-KEY
               PERFORM UNTIL CMD-KEY
                          OR ALL-OK-QUIT
                  MOVE SPACES TO DONE-SW
                                 ALL-OK-SW
                  PERFORM 1000-PROMPT THRU 1500-EXIT
                             UNTIL DONE
                  IF ALL-OK-YES
                     PERFORM 2000-UPDATE
                  END-IF
               END-PERFORM
               CLOSE SHHIST.
    
           0000-EXIT.
               GOBACK.
    
           1000-PROMPT.
               PERFORM 1100-DRAW-TITLE
               DISPLAY "  SerialNo:           "   LINE  6 POSITION 1 
                       "Work Order:           "   LINE  7 POSITION 1 
                       "   Segment:           "   LINE  8 POSITION 1 
                       "All OK? (Y,N,Q): "        LINE 14 POSITION 1 
               ACCEPT SAVE-SERNO
                           LINE 6 POSITION 13 
                                   TAB NO BEEP UPDATE
                                   ON EXCEPTION
          *                       WS-FKEY-VALUE
                                   CONTINUE
               END-ACCEPT
               IF CMD-KEY OR
                  SAVE-SERNO = SPACES
                    MOVE "Y" TO DONE-SW
                    GO TO 1500-EXIT
               END-IF
    
    
               ACCEPT SAVE-WO
                           LINE 7 POSITION 13 
                                   TAB  UPDATE
                                   ON EXCEPTION
          *WS-FKEY-VALUE
                                   CONTINUE
               END-ACCEPT
               IF CMD-KEY OR
                  SAVE-WO  = SPACES OR ZEROS
                    MOVE "Y" TO DONE-SW
                    GO TO 1500-EXIT
               END-IF
    
               ACCEPT SAVE-SEG
                           LINE 8 POSITION 13 
                                   TAB  UPDATE
                                   ON EXCEPTION
          *WS-FKEY-VALUE
                                   CONTINUE
               END-ACCEPT
               IF CMD-KEY
                    MOVE "Y" TO DONE-SW
                    GO TO 1500-EXIT
               END-IF.
    
               DISPLAY "                                  "
                                            LINE 13 POSITION 1.
           1300-ALL-OK.
               ACCEPT ALL-OK-SW LINE 14 POSITION 18 
                                   TAB  UPDATE
                                   ON EXCEPTION
          *WS-FKEY-VALUE
                                   CONTINUE
               END-ACCEPT.
               IF CMD-KEY
                    MOVE "Y" TO DONE-SW
                    GO TO 1500-EXIT
               END-IF
               DISPLAY "                        " LINE 14 POSITION 22
               IF NOT ALL-OK-VALID
                  DISPLAY "Valid values are Y, N, Q" LINE 14 POSITION 22
                  GO TO 1300-ALL-OK
               END-IF
               IF ALL-OK-QUIT OR
                  ALL-OK-YES
                    MOVE "Y" TO DONE-SW
               END-IF.
    
            1500-EXIT.
               EXIT.
    
            2000-UPDATE.
               INITIALIZE SH-KEY
               MOVE SAVE-SERNO TO SH-SERNO
               MOVE SAVE-WO  TO SH-WORKORD
               MOVE SAVE-SEG TO SH-SEGMENT
    
               START SHHIST KEY NOT < SH-KEY
               END-START
               IF NOT SUCCESSFUL-IO
                  EXIT PARAGRAPH
               END-IF.
    
               PERFORM WITH TEST AFTER UNTIL NOT RECORD-LOCK
                  READ SHHIST NEXT WITH LOCK
                  END-READ
               END-PERFORM
    
               IF AT-END OR
                 (SAVE-SERNO NOT =   SH-SERNO) OR
                 (SAVE-WO    NOT = SH-WORKORD) OR
                 (SAVE-SEG   NOT = SH-SEGMENT)
                   UNLOCK SHHIST
                   EXIT PARAGRAPH
               END-IF.
    
               MOVE "N" TO DONE-SW.
               PERFORM 2100-RECORD-VIEW UNTIL DONE.
    
           2100-RECORD-VIEW.
               PERFORM 1100-DRAW-TITLE.
               PERFORM 1200-DRAW-RECORD.
          *    1200-DRAW-RECORD displays all record fields on screen
          *       from A through V. 
    
               DISPLAY "Need to update? -Y/N-: " LINE 18 POSITION 1.
               MOVE 18 TO IO-YESNO-POS-Y.
               MOVE 24 TO IO-YESNO-POS-X.
               PERFORM 1105-PROMPT-YESNO.
               IF IO-NO
                  MOVE "Y" TO DONE-SW
                  EXIT PARAGRAPH
               END-IF.
    
               MOVE "Z" TO FIELD-LETTER.
               PERFORM UNTIL FIELD-LETTER >= "A" AND FIELD-LETTER <= "V" 
                  DISPLAY "Which field to modify? -A-V-: "
                     LINE 19 POSITION 1
                  ACCEPT FIELD-LETTER LINE 19 POSITION 31 TAB
                  END-ACCEPT
               END-PERFORM.
    
          * Pre-emptively display fields to save lines of code
               PERFORM 1100-DRAW-TITLE.
    
               DISPLAY "Current Value: " LINE 5 POSITION 1
               Display "    New value: " LINE 7 POSITION 1
    
               EVALUATE FIELD-LETTER
               WHEN "A"
                  DISPLAY "MODIFYING SH-SERNO" LINE 3 POSITION 20
                  DISPLAY SH-SERNO LINE 5 POSITION 20
                  ACCEPT  SH-SERNO LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "B"
                  DISPLAY "MODIFYING SH-WORKORD" LINE 3 POSITION 20
                  DISPLAY SH-WORKORD LINE 5 POSITION 20
                  ACCEPT  SH-WORKORD LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "C"
                  DISPLAY "MODIFYING SH-SEGMENT" LINE 3 POSITION 20
                  DISPLAY SH-SEGMENT LINE 5 POSITION 20
                  ACCEPT  SH-SEGMENT LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "D"
                  DISPLAY "MODIFYING SH-COUNT" LINE 3 POSITION 20
                  DISPLAY SH-COUNT LINE 5 POSITION 20
                  ACCEPT  SH-COUNT LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "E"
                  DISPLAY "MODIFYING SH-CUSTOMER" LINE 3 POSITION 20
                  DISPLAY SH-CUSTOMER LINE 5 POSITION 20
                  ACCEPT  SH-CUSTOMER LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "F"
                  DISPLAY "MODIFYING SH-CUST-ALPHA" LINE 3 POSITION 20
                  DISPLAY SH-CUST-ALPHA LINE 5 POSITION 20
                  ACCEPT  SH-CUST-ALPHA LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "G"
                  DISPLAY "MODIFYING SH-MAKE" LINE 3 POSITION 20
                  DISPLAY SH-MAKE LINE 5 POSITION 20
                  ACCEPT  SH-MAKE LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "H"
                  DISPLAY "MODIFYING SH-MODEL" LINE 3 POSITION 20
                  DISPLAY SH-MODEL LINE 5 POSITION 20
                  ACCEPT  SH-MODEL LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "I"
                  DISPLAY "MODIFYING SH-EQUIP" LINE 3 POSITION 20
                  DISPLAY SH-EQUIP LINE 5 POSITION 20
                  ACCEPT  SH-EQUIP LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "J"
                  DISPLAY "MODIFYING SH-SPG-CD" LINE 3 POSITION 20
                  DISPLAY SH-SPG-CD LINE 5 POSITION 20
                  ACCEPT  SH-SPG-CD LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "K"
                  DISPLAY "MODIFYING SH-COMPONENT" LINE 3 POSITION 20
                  DISPLAY SH-COMPONENT LINE 5 POSITION 20
                  ACCEPT  SH-COMPONENT LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "L"
                  DISPLAY "MODIFYING SH-JOBCD" LINE 3 POSITION 20
                  DISPLAY SH-JOBCD LINE 5 POSITION 20
                  ACCEPT  SH-JOBCD LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "M"
                  DISPLAY "MODIFYING SH-MODIFIER" LINE 3 POSITION 20
                  DISPLAY SH-MODIFIER LINE 5 POSITION 20
                  ACCEPT  SH-MODIFIER LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "N"
                  DISPLAY "MODIFYING SH-EQ" LINE 3 POSITION 20
                  DISPLAY SH-EQ LINE 5 POSITION 20
                  ACCEPT  SH-EQ LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "O"
                  DISPLAY "MODIFYING SH-PARTS" LINE 3 POSITION 20
                  DISPLAY SH-PARTS LINE 5 POSITION 20
                  ACCEPT  SH-PARTS LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "P"
                  DISPLAY "MODIFYING SH-LABOR" LINE 3 POSITION 20
                  DISPLAY SH-LABOR LINE 5 POSITION 20
                  ACCEPT  SH-LABOR LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "Q"
                  DISPLAY "MODIFYING SH-MISC" LINE 3 POSITION 20
                  DISPLAY SH-MISC LINE 5 POSITION 20
                  ACCEPT  SH-MISC LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "R"
                  DISPLAY "MODIFYING SH-METER" LINE 3 POSITION 20
                  DISPLAY SH-METER LINE 5 POSITION 20
                  ACCEPT  SH-METER LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "S"
                  DISPLAY "MODIFYING SH-INVDATE" LINE 3 POSITION 20
                  DISPLAY SH-INVDATE LINE 5 POSITION 20
                  ACCEPT  SH-INVDATE LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "T"
                  DISPLAY "MODIFYING SH-SERVTYP" LINE 3 POSITION 20
                  DISPLAY SH-SERVTYP LINE 5 POSITION 20
                  ACCEPT  SH-SERVTYP LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "U"
                  DISPLAY "MODIFYING SH-SPG-TYPE" LINE 3 POSITION 20
                  DISPLAY SH-SPG-TYPE LINE 5 POSITION 20
                  ACCEPT  SH-SPG-TYPE LINE 7 POSITION 20 
                  END-ACCEPT
               WHEN "V"
                  DISPLAY "MODIFYING SH-SPG-DESC" LINE 3 POSITION 20
                  DISPLAY SH-SPG-DESC LINE 5 POSITION 20
                  ACCEPT  SH-SPG-DESC LINE 7 POSITION 20 
                  END-ACCEPT
               END-EVALUATE.
    
          * Prompt for user input validation
               DISPLAY "Are you SURE? -Y/N-: " LINE 9 POSITION 1
               MOVE  9 TO IO-YESNO-POS-Y.
               MOVE 22 TO IO-YESNO-POS-X.
               PERFORM 1105-PROMPT-YESNO.
    
               IF IO-YES
                  REWRITE SERVHIST
                  END-REWRITE
               END-IF
               EXIT PARAGRAPH.
    
    
    
    
          * The following paragraphs should not be executed unless called
            1100-DRAW-TITLE.
               MOVE 1 to LINE-NUMBER.
               PERFORM VARYING LINE-NUMBER FROM 1 BY 1
                  UNTIL LINE-NUMBER = 24
    
                  DISPLAY SPACES LINE LINE-NUMBER SIZE 80
               END-PERFORM.
    
               DISPLAY "PARTS MARKETING MANAGEMENT" LINE 1 POSITION 28.
               DISPLAY "-FXSHHIST-1-" LINE 2 POSITION 65.
               DISPLAY "CMD-Quit" LINE 24 POSITION 37.
    
            1200-DRAW-RECORD.
               DISPLAY "A) SH-SERNO: "      LINE  3 POSITION  1
                           SH-SERNO         LINE  3 POSITION 20
                       "B) SH-WORKORD: "    LINE  4 POSITION  1
                           SH-WORKORD       LINE  4 POSITION 20
                       "C) SH-SEGMENT: "    LINE  5 POSITION  1
                           SH-SEGMENT       LINE  5 POSITION 20
                       "D) SH-COUNT: "      LINE  6 POSITION  1
                           SH-COUNT         LINE  6 POSITION 20
                       "E) SH-CUSTOMER: "   LINE  7 POSITION  1
                           SH-CUSTOMER      LINE  7 POSITION 20
                       "F) SH-CUST-ALPHA: " LINE  8 POSITION  1
                           SH-CUST-ALPHA    LINE  8 POSITION 20
                       "G) SH-MAKE: "       LINE  9 POSITION  1
                           SH-MAKE          LINE  9 POSITION 20
                       "H) SH-MODEL: "      LINE 10 POSITION  1
                           SH-MODEL         LINE 10 POSITION 20
                       "I) SH-EQUIP: "      LINE 11 POSITION  1
                           SH-EQUIP         LINE 11 POSITION 20
                       "J) SH-SPG-CD: "     LINE 12 POSITION  1
                           SH-SPG-CD        LINE 12 POSITION 20
                       "K) SH-COMPONENT: "  LINE 13 POSITION  1
                           SH-COMPONENT     LINE 13 POSITION 20
                       "L) SH-JOBCD: "      LINE  3 POSITION 40
                           SH-JOBCD         LINE  3 POSITION 60
                       "M) SH-MODIFIER: "   LINE  4 POSITION 40
                           SH-MODIFIER      LINE  4 POSITION 60
                       "N) SH-EQ: "         LINE  5 POSITION 40
                           SH-EQ            LINE  5 POSITION 60
                       "O) SH-PARTS: "      LINE  6 POSITION 40
                           SH-PARTS         LINE  6 POSITION 60
                       "P) SH-LABOR: "      LINE  7 POSITION 40
                           SH-LABOR         LINE  7 POSITION 60
                       "Q) SH-MISC: "       LINE  8 POSITION 40
                           SH-MISC          LINE  8 POSITION 60
                       "R) SH-METER: "      LINE  9 POSITION 40
                           SH-METER         LINE  9 POSITION 60
                       "S) SH-INVDATE: "    LINE 10 POSITION 40
                           SH-INVDATE       LINE 10 POSITION 60
                       "T) SH-SERVTYP: "    LINE 11 POSITION 40
                           SH-SERVTYP       LINE 11 POSITION 60
                       "U) SH-SPG-TYPE: "   LINE 12 POSITION 40
                           SH-SPG-TYPE      LINE 12 POSITION 60
                       "V) SH-SPG-DESC: "   LINE 15 POSITION 1
                           SH-SPG-DESC      LINE 15 POSITION 20.
    
            1105-PROMPT-YESNO.
               MOVE "N" TO IO-YESNO
    
               ACCEPT IO-YESNO
                  LINE     IO-YESNO-POS-Y
                  POSITION IO-YESNO-POS-X
                  TAB
               END-ACCEPT
    
               IF IO-YES OR IO-NO EXIT PARAGRAPH
               END-IF
    
               COMPUTE IO-YESNO-POS-X2 = IO-YESNO-POS-X + 5
               END-COMPUTE
    
               DISPLAY "Response must be Y or N."
                  LINE     IO-YESNO-POS-Y
                  POSITION IO-YESNO-POS-X2
    
               GO TO 1105-PROMPT-YESNO.
           END-PROGRAM.
    

    Finally, on to the error that I am getting (on the last line of code):

    cobc (GnuCOBOL) 4.0.0
    Built     Jan 18 2024 00:28:12  Packaged  Jan 18 2024 06:22:34 UTC
    C version "9.4.0"
    loading configuration file 'rm-strict.conf'
    command line:   cobc -v -x -I. -I/JDIS/DEV/akozinski/PH3/JDIS/SOURCE/COPYBOOK/ -std=rm-strict -findirect-redefines -W FXSHHIST.CBL2
    preprocessing:  FXSHHIST.CBL2 -> /tmp/cob2096858_0.cob
    return status:  0
    parsing:        /tmp/cob2096858_0.cob (FXSHHIST.CBL2)
    FXSHHIST.CBL2: in section 'MAIN-CONTROL':
    FXSHHIST.CBL2: in paragraph 'END-PROGRAM':
    FXSHHIST.CBL2:438: error: syntax error, unexpected end of file
    return status:  1
    
     

    Last edit: Michael Smith 2024-01-18
    • Chuck Haatvedt

      Chuck Haatvedt - 2024-01-18

      Michael,

      the END-PROGRAM statement requires the program-id as follows.

      END PROGRAM FXSHHIST.

       
  • Michael Smith

    Michael Smith - 2024-01-18

    .

     

    Last edit: Michael Smith 2024-01-18
    • Ralph Linkletter

      END-PROGRAM.
      FXSHHIST.CBL2: in paragraph 'END-PROGRAM':

      END-PROGRAM is in margin "A" (COLUMN 8) - Thought to be a paragraph label.
      Move it to column 12
      Change END-PROGRAM to "END PROGRAM" or "STOP RUN"
      Ralph

       

      Last edit: Ralph Linkletter 2024-01-18
      • Michael Smith

        Michael Smith - 2024-01-18

        None of this works sadly.

        END PROGRAM - same error
        STOP RUN - same error
        END PROGRAM column 12 - same error
        STOP RUN column 12 - same error
        (NO END PROGRAM OR STOP RUN) - same error

         
  • Anonymous

    Anonymous - 2024-01-18

    Suggestions, in my opinion, useful for those who are learning COBOL.

    • use the END PROGRAM statement only if you write nested programs. In other cases like this it serves no purpose and is a source of potential errors.

    • write programs with the new >>SOURCE FREE format (like all other languages C, Java, Python ... and for available large screens), do not use the old format >>SOURCE FIXED (only for COBOL and for old 80 cols green screens). This way programs are more compact and readable with fewer lines and less need to go to new line for same statement. A singke statement / verb should all be on the same line. The indentations are clearer. There is less risk of errors due to the constraints of the fixed format.

    see attached a sample of your last statements ...

     

    Last edit: Eugenio Di Lorenzo 2024-01-18
    • Michael Smith

      Michael Smith - 2024-01-18

      Sadly I get the same error with or without END PROGRAM in any column (see previous reply)

      I would like to use the SOURCE FREE format, however, when I try to compile, it complains about comments in column 7. In the source code and copybooks.

      Should I write a script that converts comments starting in column 7 into *> ? Does that syntax work anywhere in a line?

       
      • Eugenio Di Lorenzo

        perhaps the file you are using has some incorrect characters at the end of the file.

        my suggestion to use free format was related to writing new programs.
        if you already have fixed format programs then forget it.
        if you really want to try, keep in mind that there are already utilities written by someone in cobol that allow you to modify the format of cobol sources.
        I've never used them. There are several posts that deal with this topic. I think they are in the "contributions" folder.

        see also at : https://sourceforge.net/p/gnucobol/discussion/contrib/thread/e8f43ee517/

        the syntax of *> says it can be placed anywhere in a line of code. from column 1 onwards (up to column 256 I think).
        it can also be positioned to the right of a statement.
        eg MOVE A TOB *> this is a comment

         

        Last edit: Eugenio Di Lorenzo 2024-01-18
        • Michael Smith

          Michael Smith - 2024-01-18

          Converting all * to *> did allow me to compile everything with the FREE format which is pretty nice! Thank you for the syntax help :)

           
      • Vincent (Bryan) Coen

        On 18/01/2024 17:02, Michael Smith wrote:

        Sadly I get the same error with or without END PROGRAM in any column
        (see previous reply)

        I would like to use the SOURCE FREE format, however, when I try to
        compile, it complains about comments in column 7. In the source code
        and copybooks.

        Should I write a script that converts comments starting in column 7
        into *> ? Does that syntax work anywhere in a line?

        You could or simply cheat and put in on line 1 :
                >>source variable

        Now you can continue beyond cc 72.  I have done this to 40+ programs
        written as FIXED to save a bit of time before converting to FREE.

        For FREE using a good editor such as kate use in replace mode for " "
        without the quotes to "
        >" one by one if you have asterisk any where
        else and/or using *> already as a floating comment.

        Remove the / or replace for *>

        IN the block of comments starting with * only replace on the FIRST
        ocurrence i.e.,
              *   * comment **
             *   more text including *

        for   *> * comment **

        etc

        For a perform that is used in only one place use an inline perform with
        places you want to quit with
        EXIT PERFORM

        or if terminating that cycle use EXIT PERFORM CYCLE

        This does depend on how complex the perform para's are though.but it
        does save on using GO TO;s.

         
      • Simon Sobisch

        Simon Sobisch - 2024-01-18

        No, if you have fixed-form reference-format ted code, then stay with this.
        If you write me one out of a good idea to start your comments in col. 7 with > this way, it will possibly additional* compile in free-form.

        ... for the other thing (the error) I'll have a look at this next week, including if the compiler should accept an empty paragraph at the end - I think it should.

         
  • Vincent (Bryan) Coen

    Can you supply a copy of the program source with ALL copy books included and make it available here so we can try and compile it ?

    and YES must have the copy books or you can also include them as the five? separate files.

     
  • Vincent (Bryan) Coen

    Small point you are using DS and you are performing and goto paras outside the DS and that is a nono at least in my experience of using them but I must admit I try to avoid the use of it.

     
    • Michael Smith

      Michael Smith - 2024-01-18

      Ha- this is it! I commented out the DS lines of code and it compiles!! Thank you!

      Now I must ask - I am a COBOL newbie so is there anything I can do to move this section of code somewhere else to avoid this type of error?

             PROCEDURE DIVISION.
        *>   DECLARATIVES.
        *>   SHHIST-STATUS SECTION.
        *>        USE AFTER STANDARD EXCEPTION PROCEDURE ON SHHIST.
        *>   USE-SHHIST.
        *>        MOVE "I" TO FILE-TYPE.
        *>        MOVE "SHHIST  " TO STAT-FILE.
        *>        PERFORM USE-PERFORM THRU USE-EXIT.
        *>        GO TO USE-END.
      
       
      • Vincent (Bryan) Coen

        If you use the Declaratives you must only have any perform, goto code
        with that block.

        For more information read the GnuCobol Programmers Guide.

        For more look at some of the programs supplied in the Contrib area under
        the SVN tag at sourceforge/p/gnucobol

        and grab my nightly builds of ACAS which includes the OE (Order Entry)
        sub system which makes a lot of use of Declaratives, possibly too much
        but it was written by another in late 79 - 80 which I have been
        migrating it over to the GnuCobol compiler from RM v1.4 or so.

        This is still in a test / bug fix / coding mode or has been for almost 2
        months so I am taking a wee rest from it to work on testing and
        documentation of ACAS which is over due :(

        In that archive you will see one of the folders as OE with w folders src
        and one within copybooks
        the later must be set up for compiling by using command (and I have a
        Linux script for doing this called comp-oe.sh .

        Before I forget the compile process does not generate prn files (Print)
        as that line is remarked out but you could swap them around to do so.

        The other script supplied is comp-oe-diags.sh which is similar, does
        produce print files but also include full diagnostics such as runtime
        checks and full tracing of the code.

        For new systems and while testing I find this very useful to discover
        any hiding bugs and mismatched linkage sections and more such as doing
        numeric processing on non-numeric data, etc.

        In there is :

        export
        COBCPY=/home/vince/cobolsrc/oe/src/copybook:/home/vince/cobolsrc/ACAS/copybooks

        This concatenates two folders for the copy libraries for both OE and
        ACAS although the needed copybooks should be in src/copybook as far as I
        know, but I still use the above export - JIC (Just in case I missed any).

        The script comp-oe.sh  build all of the Cobol programs and the C routine
        ACCEPT_NUMERIC which is used in some of the OE programs to accept a
        number field storing it into a COMP-£ type field. Without this getting
        edited number fields is a pain.

        This is NEW code written by Chuck for us all to test and OE is the
        primary system being used to do so..
        So far it has worked a treat but I only use it in Update mode having any
        virgin data field preset to zeroes.

        Here see the programs used within Billing as this is where almost of of
        it is currently used.

        Warning OE documentation consists of only ONE document and that is the
        original System Specifications and here some of the Screen and reporting
        layouts have been changed.

        It is another job that will need to be done - creating an OR manual even
        if it is a simple one :)

        To get the nightly builds go to :

        http://www.applewood.linkpc.net/files/acas/nightlybuilds/

        There is separate archives for both ACAS and OE and even one for some
        test data that I have been using for ACAS although not complete as some
        testing is done in another folder and subject to change depending on
        what is being tested and at what level..
        Yes, I was a professional Test lead and manager as well as a Programmer,
        Operator (mainframes), IT Manager and Director to name a few of my past
        titles as well as gopher :)

        Have fun,

        Vincent

        On 18/01/2024 18:39, Michael Smith wrote:

        Ha- this is it! I commented out the DS lines of code and it compiles!!
        Thank you!

        Now I must ask - I am a COBOL newbie so is there anything I can do to
        move this section of code somewhere else to avoid this type of error?

        |PROCEDUREDIVISION. >DECLARATIVES. >SHHIST-STATUSSECTION.
        >USEAFTERSTANDARDEXCEPTIONPROCEDUREONSHHIST. >USE-SHHIST.
        >MOVE"I"TOFILE-TYPE. >MOVE"SHHIST "TOSTAT-FILE.
        >PERFORMUSE-PERFORMTHRUUSE-EXIT. >GOTOUSE-END.|

         
  • Vincent (Bryan) Coen

    DS = Declarative section

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.