Rules for fold strings?

Rules for fold strings?

8
NewbieNewbie
8

    Apr 16, 2010#1

    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

    6,675585
    Grand MasterGrand Master
    6,675585

      Apr 17, 2010#2

      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.
      Best regards from an UC/UE/UES for Windows user from Austria