Menu

changeformat - yet to find a program it works on. ??

David Wall
2021-12-28
2021-12-31
  • David Wall

    David Wall - 2021-12-28

    I realise that sounds a bit rough - but most programs I've tested it against - it crashes with the following display.

    libcob: changeformat.cob:549: error: subscript of 'WORD-TYPE' out of bounds: 0
    libcob: changeformat.cob:549: warning: implicit CLOSE of INPUT-FILE ('desimake.COB')
    libcob: changeformat.cob:549: warning: implicit CLOSE of OUTPUT-FILE ('desimake.FIX')
     Last statement of "changeformat" was at line 549 of changeformat.cob
     Started by changeformat
                desimake.COB
                desimake.FIX
                TOFIXED
    

    The 'only' program I have that actually completed successfully is 6 lines.

           PROCEDURE DIVISION.
           BEGIN.
            ACCEPT THINGY FROM ENVIRONMENT "THINGY".
            MOVE 1 TO FIELDA.
            DISPLAY THINGY LINE 10 COL 10 ACCEPT OMITTED.
            STOP RUN.
    

    Anything more complicated appears to upset it.

    Found it - found it - found it. - Found the fault - 'this is a joyful explanation'.

    A program that converts from freeformat to fixed format DOESN'T ACCEPT BLANK LINES.
    So - I've got to pre-edit my code before I can process my code - that seems a good idea - NOT.

     

    Last edit: Simon Sobisch 2021-12-28
    • Simon Sobisch

      Simon Sobisch - 2021-12-28

      @davewall: Please use formatting in your posts as this makes them much easier readable. Thanks.

      Concerning the "reported" issue: You may want to create a simple bug issue (milestone contrib, title starting with "changeformat:") assigning it to Vince about the empty line problem with the simple sample that works and with an empty line in it that does not work (two attachments).

      Concerning the introductory sentence: Did you tried "cbl-gdb" yet? There are even windows binaries at https://cobolworx.com/pages/windows.html ...

       
      • David Wall

        David Wall - 2021-12-28

        @sf-mensch - you've got me lost 'again'.
        Where do I need to 'format' what would appear to me to be a reasonably well constructed sentence - ok I didn't put a blank line between what I typed & the program output.
        OK - I edited my entry.

        On a second note:
        I 'looked' at cbl-gdb and noted that it would appear to be a text based debugger -

        In so much that you have to do some considerable entering of commands to produce the output - I'd rather use what I've developed over the last few years where the output is displayed on the screen along with the original code lines and debug output.

        see attached screen dumps of it running against the sample soh.cbl source code used in cbl-gdb as well as a run time trace listing both before and after dataname content.

        THUS - you can see why I wanted to look at Ralph L's program to :See what I was missing & vice versa.

         

        Last edit: David Wall 2021-12-28
        • Simon Sobisch

          Simon Sobisch - 2021-12-28

          sf-mensch - you've got me lost 'again'.
          Where do I need to 'format' what would appear to me to be a reasonably well constructed sentence

          My note was not as clear as it should have been, thanks for your patience with me here.
          What I did meant was: there are formatting options in this discussion board, the most important ones are the code formatting and the quoting.
          You can get to the "simple" ones in the post creation/editing (kind of a title bar in there) and use a click to format your posts this way. There is additional a circle with a question mark in there that provides the online help how to use the editor, especially how to use so called artifact links (for commits, issue tracker, forum entries, ...) and also how to specify the source language in a code block. Using those creates easier readable posts.

          Edit: I've applied those to your post and suggest you have a look at this via "edit", possibly remove those "strange characters" and look with "preview" how the result renders.

           

          Last edit: Simon Sobisch 2021-12-28
        • Simon Sobisch

          Simon Sobisch - 2021-12-28

          I 'looked' at cbl-gdb and noted that it would appear to be a text based debugger

          You may want to check out more details how the text based debugger works.
          You have pure GDB (where you use list to show the source, if you dislike the colors you can change or disable the "styling", too) and GDB's TUI mode which always shows you the source code for context.

          You can additionally use GDB frontends, that will always show you the code and often also show you the variable-content on mouse-over and/or by querying under the cursor/selection with a key and/or show you the variables you are interested in in a list/tree. I'm personally using a Vim-Frontend in the console (so "TUI" again ;-) and from time to time try the vscode integration that COBOLWorx offers.

           

          Last edit: Simon Sobisch 2021-12-28
  • Chuck H.

    Chuck H. - 2021-12-31

    Simon,

    There is a bug in the CONVERT-TO-FIXED paragraph. I moved the check for a RECORD-TYPE = BLANK to the beginning of the paragraph and added an EXIT PARAGRAPH as follows. It now works correctly. I did NOT fix or modify the free format version of the code. I assume that Vince Coen would do that.

           CONVERT-TO-FIXED.
               CALL 'scancobol' USING INPUT-RECORD SCAN-CONTROL END-CALL
    
          * start embedded test if running changeformat on itself
          *    move
          * ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
          *                '''''''''''''''''''''''''''''''''' to test-record
          *    move
          * """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
          *                """""""""""""""""""""""""""""""""" to test-record
          * end embedded test
    
          * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
          *                                                               *
          *    IF THE INPUT RECORD IS A BLANK RECORD THEN PROCESS IT      *
          *    AND EXIT THE PARAGRAPH.                                    *
          *                                                               *
          * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    
          *  output a blank record
               IF RECORD-TYPE = 'BLANK'
                   PERFORM INCREMENT-WOUTX-MAX
                   EXIT PARAGRAPH
               END-IF.
    
          *  convert and remove any comment from input-record
          *                                 free comment
               IF WORD-TYPE(WORDX-MAX) = 9
                   MOVE WORD-VALUES(WORDX-MAX) TO SCAN-VALUES
                   EVALUATE TRUE
                   WHEN INPUT-RECORD(SCAN-START + 2:) = SPACES
          *          empty comment
                       PERFORM INCREMENT-COUTX-MAX
                       MOVE '*' TO COMMENT-OUTPUT(COUTX-MAX)(7:1)
                   WHEN SCAN-END <= 67
          *          comment fits
                       PERFORM INCREMENT-COUTX-MAX
                       MOVE '*' TO COMMENT-OUTPUT(COUTX-MAX)(7:1)
                       MOVE INPUT-RECORD(SCAN-START + 2:SCAN-LENGTH - 2)
                           TO COMMENT-OUTPUT(COUTX-MAX)(7 +
                                            SCAN-START:SCAN-LENGTH - 2)
                   WHEN OTHER
          *          comment text is beyond the fixed limit
                       PERFORM CONVERT-COMMENT
                   END-EVALUATE
          *      remove the comment
                   MOVE SPACES TO INPUT-RECORD(SCAN-START:)
                   COMPUTE WORDX-MAX = WORDX-MAX - 1 END-COMPUTE
               END-IF
    
     
    👍
    1

Log in to post a comment.