Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Code Folding for Progress 4GL

2. Help
2013-02-06
2013-06-27
  • Spiralagnus
    Spiralagnus
    2013-02-06

    I'm modifying the user-defined language file to allow folding of code blocks for Progress 4GL, but the problem is that the language does not have any unique way of delineating the end of blocks of code. All blocks of code use the keyword "end", a keyword that is sometimes optional, so my code might look something like

    procedure testProc:
    
        if something then print "hello".
    
        if somethingElse then do:
            something1.
            something2.
        end.
    
        for loop:
    
        end. //end loop
    
    end. //end procedure
    

    As you can see, I can't just list all starting block keywords ("procedure", "if", "for", etc.) and use "end" as my ending block keyword, because it leads to false positives (ex. Notepad++ thinking the first "if" is the start of a code block). I want to be able to fold all blocks of code that end with "end".

    Any suggestions on how to create fold opening and closing points for blocks of code?

     
  • Loreia2
    Loreia2
    2013-02-07

    Hi Spiralagnus,

    Solution1:
    don't use "if" as folding point, use "do" instead.
    "if" and "then" can be regular Keywords1-8

    Solution2:
    Define "Folding in code 2" as:
    Open: procedure if for do
    Middle: <empty>
    Close: end then

    Define "Keyword1" as: "then do" <with quotes="">
    Define Comment line as: //
    Define Operator1 as: ". :" <without quotes="">

    You should end up with something like:

    This is based on your sample code, if this clashes with something else, let me know.

    BR,
    Loreia

     
    • Spiralagnus
      Spiralagnus
      2013-02-07

      Okay, I managed to create an effective code 2 style folding pattern as follows:

      Open:
      procedure do "for each" repeat function

      Close:
      end

      However, I now have a new problem. When I open up an existing Progress file, Notepad++ reads the starting and ending folding points incorrectly. For instance, take the code block below (unfolded and folded):

      Misaligned text unfolded

      Misaligned text folded

      Now, the folding points start to realign themselves as I start to make changes to the file. For instance, this is what happens when I add a space to the end of the first if statement:

      Text starting to align

      I can realign all the folding points by going to each line and adding and then deleting a space at the end of the line. In fact, I have a macro that does just that, which I run using the "Run a Macro Multiple Times..." option:

      Text aligned

      However, I start to lose the alignment on the lower folding points when I start to make modifications to lines of code farther up:

      Text misaligned again

      I would appreciate any suggestions you may have. Thanks again for all of your help!

       
  • Loreia2
    Loreia2
    2013-02-08

    Let me guess, you are using UNIX end of line convention (just \n) and some version older than newly released 6.3? Because this sounds like a bug that I patched in latest UDL version. Please upgrade to Notepad++ version 6.3 and report here if it is working for you.

    BR,
    Loreia

     
    • Spiralagnus
      Spiralagnus
      2013-02-11

      I'm using Notepad++ 6.3, the latest version (I just downloaded and installed it last week). However, your comment about Unix and EOL convention got me thinking. Yes, the files I'm creating sit on a Unix server, and I download, edit and re-upload them using NppFTP.

      It turns out that if I go to Edit -> EOL Conversion -> Windows Format, the problem goes away (i.e. all folding points line up correctly). When I switch it back to Unix/OSX Format, the problem returns. However, I don't want to do this manually every time I open a Unix file. Is there a way to either a) convert to Windows EOL by default, or b) get Notepad++/UDL to read the Unix EOL convention correctly for folding purposes? Please let me know.

      Thanks again for all of your help.

       
  • Loreia2
    Loreia2
    2013-02-11

    Hi,

    can you send me file that can be used to reproduce the problem as well as your userDefineLang.xml file? I'd love to fix this.

    udlv20 at_ gmail _dotcom

    Br,
    Loreia

     
    • Spiralagnus
      Spiralagnus
      2013-02-11

      Files are sent. Thanks again for your help.

       
      • Spiralagnus
        Spiralagnus
        2013-02-12

        Please let me know when this problem has been resolved and whether there is anything else I can do to help. Thanks!

         
  • Loreia2
    Loreia2
    2013-02-12

    Thanks for files, I hope to be able to look into the details of thins by the end of week.

    BR,
    Loreia

     
    • Spiralagnus
      Spiralagnus
      2013-02-21

      I just wanted to follow up to find out if you've learned anything from the files I sent. I also wanted to add that the problem reasserts itself if I try to add delimiters to the Operator1 style under Operators & Delimiters (even if the EOF style is Windows), although everything is fine if I add delimiters to the Operator2 style.

      Any thoughts?

      Thanks again for all of your help.

       
  • jber101
    jber101
    2013-06-26

    I have experienced the same problem as Spiralagnus: Code collapse works fine if in Windows format, but is misaligned in Unix format. I am using v6.3.2. Has there been a solution?

    Best
    J

     
  • jber101
    jber101
    2013-06-27

    Loreia,

    Works like a charm! Thanks!

    j