While opening and closing braces must match, there is no such limitation for open and close fold strings. For UltraEdit it is enough if there is a close fold string for every open fold string. If the close fold string really belongs to the open fold string is not evaluated by UltraEdit as this would require knowledge about the language itself.
So if you have a file which contains for example
FUNCTION and in the next lines there are no other open or close fold strings up to a line with
ENDCASE, UltraEdit would suggest code folding from the line with
FUNCTION to the line with
ENDCASE. Of course such a file could not be compiled as this is a big error in syntax structure.
I don't know anything about Visual FoxPro and therefore have taken a quick look on the Wikipedia page about Visual FoxPro. It looks like the
DO CASE ... CASE ... CASE ... OTHERWISE ... ENDCASE structure is like in C/C++/Javascript/...
Code: Select all
switch (variable):
{
case 1: // code
break;
case 2: // code
break;
case 3: // code
break;
default: // code
break;
}
OTHERWISE respectively
default are just optional, not required. So a case block ends
- where next case block begins, or
- where the default block begins, or
- where the switch statement ends.
If every switch statement contains a default block as required according to MISRA C/C++ for safe code, but not required by C/C++, there would be no problem to code folde also case blocks. And same is true for Visual FoxPro: If there would be always an
OTHERWISE block, code folding of
CASE blocks would be no problem.
But in Visual FoxPro as well as in C/C++/Javascript/... often option 3 is used and that's bad for code folding of case blocks.
As general text editor UltraEdit has no intellisense for any programming language, UE does not know that
ENDCASE marks end of a
DO CASE block and marks also end of a
CASE block if there is no
OTHERWISE block (and IF here!).
The result is that when UltraEdit's code folding engine reaches the line with
ENDCASE and there is no
OTHERWISE block, UE interprets this line as end of the last
CASE block and the
DO CASE block is still not terminated.
The only solution for this situation is to go without code folding for
CASE blocks. Remove
CASE from open and close fold strings definition lines and remove also
OTHERWISE.
You have to be satisfied with code folding for the entire
DO CASE and fold a
CASE block when needed by manually selecting the lines and hiding all lines except first line of the selection using
View - Hide/Show Lines - Collapse All (by hotkey).
An automatic code folding for
CASE blocks would be possible only if always a line with
OTHERWISE is present.
In general this limitation of automatic code folding should not be a problem as a
CASE block should not contain so many lines that all of them cannot be displayed on half of the screen.