How to get COBOL procedures/functions listed also in Function List view?

How to get COBOL procedures/functions listed also in Function List view?

131
Basic UserBasic User
131

    Apr 27, 2022#1

    I edit COBOL files in UE on occasion, but the Function List view doesn't seem to work. I see the various divisions and sections, but no procedures/functions.

    Do I miss something?

    My COBOL files do get highlighted, so that's okay. There are just no list of procedures/functions in the Function List.

    6,688587
    Grand MasterGrand Master
    6,688587

      Apr 28, 2022#2

      It looks like the user-submitted syntax highlighting wordfile for COBOL needs an improvement regarding to the regular expression search strings used to find strings to display in the Function List view in a hierarchical or a flat list. Open a COBOL file and next the Function List view, right click into the view and click on the last context menu item Configuration. A dialog window opens where the Perl or the UltraEdit regular expression search strings can be defined stored in the wordfile for syntax highlighting COBOL files.

      The wordfile cobol.uew can be opened by clicking at Advanced - Settings or Configuration - Editor display - Syntax highlighting on the button Open with COBOL displayed left in the list of Installed wordfiles.

      It contains on 2022-04-28 the lines:

      Code: Select all

      /TGBegin "Code"
      /TGFindStr = "^[ \t\d]*(.* Division).*"
      /TGFindStr = "^[ \t\d]*(.* Section).*"
      /TGEnd
      /Regexp Type = Perl
      I don't know anything about COBOL. So if you want my help on creating the function string definitions for a hierarchical function list and make further improvements on the wordfile for COBOL like giving the color groups also meaningful names useful for color/font style settings in the Manage Themes dialog window I would need a good COBOL example file for testing and a link to a web site explaining the syntax rules of COBOL.
      Best regards from an UC/UE/UES for Windows user from Austria

      131
      Basic UserBasic User
      131

        Apr 28, 2022#3

        Mofi,
        My COBOL wordfile file looks identical to the one downloadable from page User-submitted wordfiles for UltraEdit/UEStudio, direct download: COBOL.

        Here's a sample COBOL program:

        Code: Select all

              ****************************************************************
              *  This program demonstrates the following Language            *
              *  Environment callable                                        *
              *  services : CEEMOUT, CEELOCT, CEEDATE                        *
              ****************************************************************
              ****************************************************************
              **           I D          D I V I S I O N                    ***
              ****************************************************************
               Identification Division.
               Program-id.    AWIXMP.
              ****************************************************************
              **           D A T A      D I V I S I O N                    ***
              ****************************************************************
               Data Division.
               Working-Storage Section.
              ****************************************************************
              **  Declarations for the local date/time service.
              ****************************************************************
               01   Feedback.
               COPY CEEIGZCT
                02   Fb-severity      PIC 9(4) Binary.
                02   Fb-detail        PIC X(10).
               77   Dest-output       PIC S9(9) Binary.
               77   Lildate           PIC S9(9) Binary.
               77   Lilsecs           COMP-2.
               77   Greg              PIC X(17).
              ****************************************************************
              **  Declarations for messages and pattern for date formatting.
              ****************************************************************
               01   Pattern.
                02                    PIC 9(4) Binary Value 45.
                02                    PIC X(45) Value
                    "Today is Wwwwwwwwwwwwz, Mmmmmmmmmmz ZD, YYYY.".
        
               77   Start-Msg         PIC X(80) Value
                    "Callable Service example starting.".
        
               77   Ending-Msg        PIC X(80) Value
                    "Callable Service example ending.".
        
               01 Msg.
                 02 Stringlen         PIC S9(4) Binary.
                 02 Str               .
                  03                  PIC X Occurs 1 to 80 times
                                             Depending on Stringlen. 
              ****************************************************************
              **           P R O C      D I V I S I O N                    ***
              ****************************************************************
               Procedure Division.
               000-Main-Logic.
                   Perform 100-Say-Hello.
                   Perform 200-Get-Date.
                   Perform 300-Say-Goodbye.
                   Stop Run.
              **
              ** Setup initial values and say we are starting.
              **
               100-Say-Hello.
                   Move 80 to Stringlen.
                   Move 02 to Dest-output.
                   Move Start-Msg to Str.
                   CALL "CEEMOUT" Using Msg   Dest-output Feedback.
                   Move Spaces to Str.        CALL "CEEMOUT" Using Msg Dest-output Feedback.
              **
              ** Get the local date and time and display it.
              **
               200-Get-Date.
                   CALL "CEELOCT" Using Lildate Lilsecs     Greg      Feedback.
                   CALL "CEEDATE" Using Lildate Pattern     Str       Feedback.
                   CALL "CEEMOUT" Using Msg     Dest-output Feedback.
                   Move Spaces to Str.
                   CALL "CEEMOUT" Using Msg     Dest-output Feedback.
              **
              ** Say Goodbye.
              **
               300-Say-Goodbye.
                   Move Ending-Msg to Str.
                   CALL "CEEMOUT" Using Msg     Dest-output Feedback.
               End program AWIXMP.
        The "functions" in the above sample COBOL program would be:
        • 000-Main-Logic.
        • 100-Say-Hello.
        • 200-Get-Date.
        • 300-Say-Goodbye.
        COBOL functions are declared after the Procedure Division and begin in column 8.
        UeCobol.jpg (18.43KiB)
        Current Function List view for the sample file

        6,688587
        Grand MasterGrand Master
        6,688587

          Apr 30, 2022#4

          The wordfile cobol.uew on page User-submitted wordfiles for UltraEdit/UEStudio is updated with the improvements as described below. The wordfile cobol_names.uew is additionally available in the wordfiles repository on GitHub  The two files are identical with exception of the first line. The user-submitted wordfile cobol.uew as of 2024-04-30 had in the first line:

          File Extensions = COB CBL CPY File Names = COBLIB COBLIBRP

          That is invalid. It is not really possible to use in one wordfile File Extensions = and File Names =. UltraEdit interprets everything after File Extensions = as space separated list of file extensions up to the end of the line and everything after File Names = as space separated list of file names up to the end of the line. So such a definition results in not only applying the COBOL syntax highlighting language as defined in this wordfile to the files coblib, coblibrp, *.cob, *.cbl, *.cpy, but also to *.file, *.names, *.=, *.coblib and *.coblibrp. Such files most likely never exist, but the definition is nevertheless invalid.

          The help page with title Syntax Highlighting in UltraEdit for Windows v2022.0.0.102 contains:

          File Names/Extensions Considerations
          The following items must be considered if using both File Names and File Extensions options in the same wordfile:
          1. Names including spaces may not be specified with the File Names option.
          2. The File Names option may not be used in conjunction with the File Extensions option.
          3. If a language is defined using the File Names option, and a different language within the same wordfile is specified using the File Extensions option and the definitions overlap, the language defined with the File Names option must have a lower language number, i.e.:

            Example 1 - won't work:
            /L6"XML General" XML_LANG Noquote ... File Extensions = XML XUL XSD XSL XSLT
            /L12"XML Special" XML_LANG Noquote ... File Names = ThisIsJustAFile.xml

            Example 2 - will work:
            /L6"XML Special" XML_LANG Noquote ... File Names = ThisIsJustAFile.xml
            /L12"XML General" XML_LANG Noquote ... File Extensions = XML XUL XSD XSL XSLT
          I used the information provided by Tutorials Point COBOL Tutorial to enhance the wordfile for COBOL. I have not read all COBOL tutorial pages carefully and have not used all examples to test the syntax highlighting and the function list enhancements. Therefore it is possible that something is not working correct, i.e. strings are missing in the Function List view or there are strings listed which should not be in this list.

          My goal on enhancing the wordfile was to get highlighted only strings which are valid in the file according to syntax rules of COBOL as much as possible and get listed in Function List view only valid strings, i.e. their first character is within the columns 8 to 11. For that reason all regular expression strings begin with ^(?:[0-9]{6} {1,4}| {7,10}) which means:

          ^ ... find at beginning of a line
          (?:...|...) either a string matched by the first or the second expression defined in a non-marking/non-capturing group
          [0-9]{6} {1,4} ... with first expression searching exactly for six digits followed by one to four spaces and
           {7,10} .. with second expression searching for seven to ten spaces.

          Please let me know if this Perl regular expression part is too restrictive and let me know with examples the reason.

          The COBOL wordfiles have following enhancements:
          1. The keyword Nocase is moved left after the language marker keyword as that is the typical position of this keyword in wordfiles. That makes no change on syntax highlighting.
          2. The Line Comment Valid Columns = definition is modified to allow only column 7 as valid column for an asterisk to be interpreted as the beginning of a line comment. Please let me know if this is too restrictive.
          3. The list of delimiters is reduced to those characters being allowed in a COBOL file and are not part of a word. The horizontal tab character is still not in the list. A horizontal tab does not belong to the list of allowed characters according to basic syntax page which is logic in my opinion as COBOL syntax is position dependent. For that reason no Perl regular expression search string contains anymore \t to match a horizontal tab character. If a horizontal tab is used at beginning of a line, the line is always ignored by all regular expressions.
          4. The function string definitions are for a hierarchical function list with the following groups:
            • Author (on existing)
            • Program identifier (on existing)
            • Divisions (only the four possible)
              • Sections (on existing) ... variable as the procedure division can have variable sections
            • Procedures (on existing)
            Note: It is not possible to limit the search for procedures to just the procedures division block. So I hope this expression works fine and does not produce too many false positives. The expression contains a negative look-ahead with an on OR expression to exclude three false positives I have seen already on testing the wordfile on examples copied from Tutorials Point COBOL tutorial pages. There can be other strings added to this OR expression inside the look-ahead expression. Please let me know them.
          5. The open/close fold strings are extended to offer also code folding of divisions, sections and multi-line loops.
          6. /Word Select Include = - is added to get interpreted the non-word character hyphen as word character on executing the command Select word like with double clicking on a word. I think the COBOL programmers will like that.
          7. The color groups have all names now which helps on configuring the colors and font styles for the syntax language COBOL in the Manage Themes dialog window.
          8. The color groups Operators, Brackets and Delimiters are added by me which could be very useful with appropriate color / font style settings.
          I did not modify any word list. The words in the first five color groups were already perfect which means all sorted well, no duplicates and no invalid words.
          Best regards from an UC/UE/UES for Windows user from Austria

          131
          Basic UserBasic User
          131

            May 02, 2022#5

            Mofi,

            Your cobol.uew file works well.

            Thank you for all you do for the UE community!