Rules for fold strings?

Syntax highlighting, code folding, brace matching, code indenting, and function list

Rules for fold strings?

Postby Klaatu » Fri Apr 16, 2010 4:00 pm

I've tried to use these as open and close fold strings:
Code: Select all
/Open Fold Strings = "Do" "For" "Func" "If" "#Region" "Select" "Switch" "While" "While" "With"
/Close Fold Strings = "Until" "Next" "EndFunc" "EndIf" "#EndRegion" "EndSelect" "EndSwitch" "Wend" "WEnd" "EndWith"

Everything seems to work alright, as you can imagine, except the while...wend loops.

While the language itself is not case sensitive, it makes it easier to read the code when language elements are in the "proper" case. One small niggle is that some people like "While...Wend" while others prefer to use "While...WEnd". I'd like a syntax file that allowed both to work, but so far have been unsuccessful in getting folding to work properly with both styles.

So, I was wondering what the rules were? The built-in help doesn't really say if you can use the same "word" more than once, and a search of the forum didn't turn up anything I could find stating whether something like this would work or not.

Or maybe I'm going about it the wrong way. Any suggestions to make it work would be welcome. TIA
User avatar
Klaatu
Newbie
 
Posts: 5
Joined: Thu Feb 24, 2005 12:00 am
Location: Ceti-Alpha 5

Re: Rules for fold strings?

Postby Mofi » Sat Apr 17, 2010 11:48 am

Is your folding definition for BASIC? Yes, then please read Code folding for Microsoft Visual Basic 2008 and Code folding issue with my BASIC files.

To answer your questions:

  1. The code folding strings are case sensitive if the first line of the syntax highlighting language definition does not contain keyword Nocase. Otherwise using Nocase results in interpreting the code folding strings also not case sensitive.
  2. It is completely useless to list a word twice. So you should delete second While in your open code folding strings. When first language definition line contains keyword Nocase you can also remove WEnd (or Wend).
  3. Folding strings are not searched in pairs like the matching braces. UltraEdit searches downwards for every open fold string found for any close fold string. So for example using

    Code: Select all
    /Open Fold Strings = "Do" "For" "Func" "If" "#Region" "Select" "Switch" "While" "With"
    /Close Fold Strings = "EndWith" "Wend" "EndSwitch" "EndSelect" "#EndRegion" "EndIf" "EndFunc" "Next" "Until"

    results in same code folding as your fold strings.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Syntax Highlighting