Problem with COBOL program



  • I have been using Notepad++ to develop a COBOL program using the COBOL language syntax add-in. I experienced an unusual situation as follows.

    I had a line

    03 msg-eof pic x(20) value “EOF - no records”.

    which showed correctly in NP++ i.e. starting in column 8 and finishing before column 72, as COBOLcode in FIXED format should do.

    When I compiled the program I was getting all sorts of errors which did not seem logical or possible. So I loaded the program into 2 other IDEs (Micro Focus Visual COBOL and OpenCobolIDE} which showed that the line had somehow extended beyond column 72:

    03 msg-eof pic x(20) value “EOF - no records”.

    (where column 72 was between “EOF” and “-no records.” )

    and this was causing a multitude of subsequent errors in the program code which followed.

    Having corrected this code misplacement in the other IDEs I then loaded the program in NP++ and it compiled correctly.

    So has anyone any idea how this misrepresentation of program code could occur in N++? It caused me hours of searching and puliing out my hair looking for what was really a none existant coding error.



  • @PaoloRicardo

    i don’t know cobol or the syntax add-in, but maybe the vertical edge option will help a bit in spotting and preventing to exceed a fixed length of a 72 characters per line.

    please go to settings > preferences > editing, enable show vertical edge and set the number of columns you need.

    this is how the line mode will look like, showing a border:
    Imgur

    and this is the background mode, which will be invisible if all is ok, but highlight everything that exceeds your chosen number of characters per line:
    Imgur



  • Meta

    I already had a vertical edge setting of 72.
    The problem is that NP++ showed the line in question as being within this limit but, as I said, using other IDEs, the line went beyond column 72. So I don’t know why NP++ should show a different view than the other IDEs.



  • @PaoloRicardo

    So I don’t know why NP++ should show a different view than the other IDEs.

    neither do i, if your file did not contain any non standard hidden characters.

    please test the following, to verify, if a clean notepad++ would do the same, with either the original file, if you still have it, or by trying to reproduce this on the newest notepad++ version:

    • download the notepad++ 7.6.6. portable version from >>> here <<<.
      (the portable version does not require any installation and runs completely independent and isolated from your installed version. all custom settings, as well as any stuff you might want to try at the portable version, will not modify your installed version)

    • extract npp.7.6.6.bin.zip to e.g. your desktop.

    • important note: make sure to close all instances of notepad++ that might be running, before starting the portable version at the next step.

    • open the extracted npp.7.6.6.bin folder and start this portable version by double-clicking on notepad++.exe inside this folder.
      (note: notepad++.exe will just be seen as notepad++, if you have enabled to hide all known file extensions at your explorer settings)



  • @Meta-Chuh said:

    if your file did not contain any non standard hidden characters.

    @PaoloRicardo: @Meta-Chuh’s idea of hidden characters is reasonable. And it might not even be hidden characters: I don’t know how COBOL works, but if you had Unicode characters, some take more than one byte to store, and if the COBOL compiler counts “bytes” instead of counting “characters” on a given line, that might do it. (And in fact, if you used smart quotes “”, as was rendered by the forum, instead of using a plain ASCII quote marks "", those would be encoded as multibyte characters in a UTF-8 file.)

    Also, maybe you were using a proportional font, rather than monospaced font: Settings > Style Configurator > Language: Global Styles > Style: Default Style > Font name: ____. Also checking Style: Global Override > Font name, and any of the font names in Language: COBOL styles. For example, I just put the "EOF - no records" straddling character 72 – once with the quotes, and once without; then I change the font of the STRING style to a non-proportional font (Juice ITC) which has very different character spacing.

    Even though the first row has more characters (since it has the final "., and the second does not), the second row looks longer.



  • Meta/Peter

    If it was hidden characters I don’t know how they could have got into the text especially for only one line. There are 55 lines before the ‘funny’ one and lines 49-56 are of exactly the same format (though content is different.)

    The only “” I use is from my laptop keyboard - as far as I’m aware that doesn’t give smart quotes.

    Encoding is standard/default UTF-8 and the Global Styles and Global Override font is Consolas. There is no font name shown under COBOL.

    Anyway, thanks for your replies. It seems to have been an isolated incident.

    Paul



  • @PaoloRicardo

    It seems to have been an isolated incident.

    eventually bookmark this topic if you continue using notepad++ for cobol, so if it ever happens again, you can quickly crosscheck with the portable version from above and peter’s information.

    best regards


Log in to reply