Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
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
if something then print "hello".
if somethingElse then do:
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?
don't use "if" as folding point, use "do" instead.
"if" and "then" can be regular Keywords1-8
Define "Folding in code 2" as:
Open: procedure if for do
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.
Okay, I managed to create an effective code 2 style folding pattern as follows:
procedure do "for each" repeat function
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):
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:
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:
However, I start to lose the alignment on the lower folding points when I start to make modifications to lines of code farther up:
I would appreciate any suggestions you may have. Thanks again for all of your help!
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.
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.
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
Files are sent. Thanks again for your help.
Please let me know when this problem has been resolved and whether there is anything else I can do to help. Thanks!
Thanks for files, I hope to be able to look into the details of thins by the end of week.
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.
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?
Hi Blue J,
you can use latest beta version, links can be found in this thread:
Works like a charm! Thanks!